#include <iostream>
using namespace std;
int main() {
int m, n;
cin >> m >> n;
int A[m][n], AAt[m][m];
for(int i=0; i<m; i++){
for(int j=0; j<n; j++){
cin >> A[i][j];
}
}
for(int i=0; i<m; i++){
for(int j=0; j<m; j++){
int tmp=0;
for(int k=0; k<n; k++){
tmp+=A[i][k]*A[j][k];
}
AAt[i][j]=tmp;
}
}
for(int i=0; i<m; i++){
for(int j=0; j<m; j++){
cout << AAt[i][j] << " ";
}
cout << endl;
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1haW4oKSB7CglpbnQgbSwgbjsKCWNpbiA+PiBtID4+IG47CglpbnQgQVttXVtuXSwgQUF0W21dW21dOwoJZm9yKGludCBpPTA7IGk8bTsgaSsrKXsKCQlmb3IoaW50IGo9MDsgajxuOyBqKyspewoJCQljaW4gPj4gQVtpXVtqXTsKCQl9Cgl9Cglmb3IoaW50IGk9MDsgaTxtOyBpKyspewogICAgICAgIGZvcihpbnQgaj0wOyBqPG07IGorKyl7CiAgICAgICAgICAgIGludCB0bXA9MDsKICAgICAgICAgICAgZm9yKGludCBrPTA7IGs8bjsgaysrKXsKICAgICAgICAgICAgICAgIHRtcCs9QVtpXVtrXSpBW2pdW2tdOwogICAgICAgICAgICB9CiAgICAgICAgICAgIEFBdFtpXVtqXT10bXA7CiAgICAgICAgfQogICAgfQogICAgZm9yKGludCBpPTA7IGk8bTsgaSsrKXsKCQlmb3IoaW50IGo9MDsgajxtOyBqKyspewoJCQljb3V0IDw8IEFBdFtpXVtqXSA8PCAiICI7CgkJfQoJCWNvdXQgPDwgZW5kbDsKCX0KCXJldHVybiAwOwp9