// verification-helper: PROBLEM https://onlinejudge.u-aizu.ac.jp/courses/lesson/2/ITP1/7/ITP1_7_D
#include "src/math/matrix.hpp"
#include <iostream>
using namespace std;
int main() {
int n, m, l;
cin >> n >> m >> l;
Matrix<long long> a(n, m), b(m, l);
for (int i = 0; i < n; ++i)
for (int j = 0; j < m; ++j) cin >> a[i][j];
for (int i = 0; i < m; ++i)
for (int j = 0; j < l; ++j) cin >> b[i][j];
auto c = a * b;
for (int i = 0; i < n; ++i) {
for (int j = 0; j < l; ++j) {
if (j) cout << " ";
cout << c[i][j];
}
cout << endl;
}
return 0;
}
#line 1 "test/math/matrix/aoj_itp1_7_d.test.cpp"
// verification-helper: PROBLEM https://onlinejudge.u-aizu.ac.jp/courses/lesson/2/ITP1/7/ITP1_7_D
#line 1 "src/math/matrix.hpp"
#include <cassert>
#include <cstddef>
#include <initializer_list>
#include <vector>
template<class T>
class Matrix {
private:
std::vector<std::vector<T>> mat;
public:
Matrix(std::size_t n) : mat(n, std::vector<T>(n)) {}
Matrix(std::size_t n, std::size_t m) : mat(n, std::vector<T>(m)) {}
Matrix(std::initializer_list<std::vector<T>> init) : mat(init) {}
Matrix(std::vector<std::vector<T>> &mat) : mat(mat) {}
[[nodiscard]] std::size_t height() const { return mat.size(); }
[[nodiscard]] std::size_t width() const { return mat[0].size(); }
std::vector<T> &operator[](std::size_t k) { return mat[k]; }
std::vector<T> const &operator[](std::size_t k) const { return mat[k]; }
Matrix &operator+=(Matrix const &b) {
std::size_t n = height(), m = width();
assert(n == b.height() && m == b.width());
for (std::size_t i = 0; i < n; ++i)
for (std::size_t j = 0; j < m; ++j) (*this)[i][j] += b[i][j];
return *this;
}
Matrix &operator-=(Matrix const &b) {
std::size_t n = height(), m = width();
assert(n == b.height() && m == b.width());
for (std::size_t i = 0; i < n; ++i)
for (std::size_t j = 0; j < m; ++j) (*this)[i][j] -= b[i][j];
return *this;
}
Matrix &operator*=(Matrix const &b) {
std::size_t n = height(), m = b.width(), p = width();
assert(p == b.height());
std::vector<std::vector<T>> c(n, std::vector<T>(m));
for (std::size_t i = 0; i < n; ++i)
for (std::size_t j = 0; j < m; ++j)
for (std::size_t k = 0; k < p; ++k) c[i][j] += (*this)[i][k] * b[k][j];
mat.swap(c);
return *this;
}
Matrix operator+(Matrix const &b) const { return Matrix(*this) += b; }
Matrix operator-(Matrix const &b) const { return Matrix(*this) -= b; }
Matrix operator*(Matrix const &b) const { return Matrix(*this) *= b; }
static Matrix identity(std::size_t n) {
Matrix id(n);
for (std::size_t i = 0; i < n; ++i) id[i][i] = 1;
return id;
}
[[nodiscard]] Matrix pow(long long n) const {
Matrix res = Matrix::identity(height()), tmp(*this);
while (n > 0) {
if (n & 1) res *= tmp;
tmp *= tmp;
n >>= 1;
}
return res;
}
};
#line 4 "test/math/matrix/aoj_itp1_7_d.test.cpp"
#include <iostream>
using namespace std;
int main() {
int n, m, l;
cin >> n >> m >> l;
Matrix<long long> a(n, m), b(m, l);
for (int i = 0; i < n; ++i)
for (int j = 0; j < m; ++j) cin >> a[i][j];
for (int i = 0; i < m; ++i)
for (int j = 0; j < l; ++j) cin >> b[i][j];
auto c = a * b;
for (int i = 0; i < n; ++i) {
for (int j = 0; j < l; ++j) {
if (j) cout << " ";
cout << c[i][j];
}
cout << endl;
}
return 0;
}