structmatrix { int dimx, dimy; // 矩阵维度 ll m[100][100]; matrix(int x = 60, int y = 60) { // 构造函数 ms(m, 0); dimx = x, dimy = y; } matrix operator*(const matrix &x) const { matrix c; for (int i = 0; i < dimx; ++i) for (int j = 0; j < x.dimy; ++j) for (int k = 0; k < dimy; ++k) c.m[i][j] = (c.m[i][j] + m[i][k] * x.m[k][j]) % mod; return c; } };
matrix qpow2(matrix a, int b){ matrix ans = a;b--; while (b) { if (b & 1) ans = ans * a; a = a * a; b >>= 1; } return ans; } intmain(){ int n = read(), m = read(); matrix a(2 * n, 2 * n); for (int i = 0; i < n; ++i){ for (int j = 0; j < n; ++j){ a.m[i][j + n] = a.m[i][j] = read(); } } for (int i = n; i < 2 * n; ++i) a.m[i][i] = 1; a = qpow2(a, m); for (int i = 0; i < n; ++i){ for (int j = n; j < 2 * n; ++j){ printf("%d", a.m[i][j]); if (j != 2 * n - 1) putchar(' '); elseputchar(10); } } return0; }