#include <bits/stdc++.h>
using namespace std;
/***template***/
#define ll long long
#define mat_size 3
#define mod 1000000007
long long mod1, col_num = mat_size, row_num = mat_size;
long long mat[mat_size][mat_size], temp[mat_size][mat_size], res[mat_size][mat_size];
void matpower(long long pwr)
{
long long i, j, k, s;
if (pwr == 0)
{
for (i = 0; i < row_num; i++)
{
for (j = 0; j < col_num; j++)
{
if (i != j)
res[i][j] = 0;
else
res[i][j] = 1;
}
}
return ;
}
matpower(pwr/2);
for (i = 0; i < col_num; i++)
{
for (j = 0; j < row_num; j++)
{
temp[i][j] = res[i][j];
}
}
for (i = 0; i < col_num; i++)
{
for (j = 0; j < row_num; j++)
{
s = 0;
for (k = 0; k < row_num; k++)
s = (s + (temp[i][k]*temp[k][j])%mod)%mod;
res[i][j] = s;
}
}
if (pwr%2 == 1)
{
for (i = 0; i < row_num; i++)
{
for (j = 0; j < row_num; j++)
{
temp[i][j] = res[i][j];
}
}
for (i = 0; i < row_num; i++)
{
for (j = 0; j < col_num; j++)
{
s = 0;
for (k = 0; k < col_num; k++)
s = (s + (mat[i][k]*(temp[k][j]))%mod)%mod;
res[i][j] = s;
}
}
}
}
int main ()
{
mat[0][0] = 2;
mat[0][1] = 2;
mat[0][2] = 3;
mat[1][0] = 2;
mat[1][1] = 2;
mat[1][2] = 4;
mat[2][0] = 5;
mat[2][1] = 5;
mat[2][2] = 5;
mod1=1000;// Jodi mod constant na hoi
matpower(5);
for(int i=0;i<mat_size;i++)
{
for(int j=0;j<mat_size;j++)
{
printf("%lld ",res[i][j]);
}
printf("\n");
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7Ci8qKip0ZW1wbGF0ZSoqKi8KI2RlZmluZSBsbCAgICAgICAgICAgICAgICAgICBsb25nIGxvbmcKI2RlZmluZSBtYXRfc2l6ZSAzCiNkZWZpbmUgbW9kIDEwMDAwMDAwMDcKbG9uZyBsb25nIG1vZDEsIGNvbF9udW0gPSBtYXRfc2l6ZSwgcm93X251bSA9IG1hdF9zaXplOwpsb25nIGxvbmcgbWF0W21hdF9zaXplXVttYXRfc2l6ZV0sIHRlbXBbbWF0X3NpemVdW21hdF9zaXplXSwgcmVzW21hdF9zaXplXVttYXRfc2l6ZV07CnZvaWQgbWF0cG93ZXIobG9uZyBsb25nIHB3cikKewogICAgbG9uZyBsb25nIGksIGosIGssIHM7CiAgICBpZiAocHdyID09IDApCiAgICB7CiAgICAgICAgZm9yIChpID0gMDsgaSA8IHJvd19udW07IGkrKykKICAgICAgICB7CiAgICAgICAgICAgIGZvciAoaiA9IDA7IGogPCBjb2xfbnVtOyBqKyspCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIGlmIChpICE9IGopCiAgICAgICAgICAgICAgICAgICAgcmVzW2ldW2pdID0gMDsKICAgICAgICAgICAgICAgIGVsc2UKICAgICAgICAgICAgICAgICAgICByZXNbaV1bal0gPSAxOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIHJldHVybiA7CiAgICB9CiAgICBtYXRwb3dlcihwd3IvMik7CiAgICBmb3IgKGkgPSAwOyBpIDwgY29sX251bTsgaSsrKQogICAgewogICAgICAgIGZvciAoaiA9IDA7IGogPCByb3dfbnVtOyBqKyspCiAgICAgICAgewogICAgICAgICAgICB0ZW1wW2ldW2pdID0gcmVzW2ldW2pdOwogICAgICAgIH0KICAgIH0KICAgIGZvciAoaSA9IDA7IGkgPCBjb2xfbnVtOyBpKyspCiAgICB7CiAgICAgICAgZm9yIChqID0gMDsgaiA8IHJvd19udW07IGorKykKICAgICAgICB7CiAgICAgICAgICAgIHMgPSAwOwogICAgICAgICAgICBmb3IgKGsgPSAwOyBrIDwgcm93X251bTsgaysrKQogICAgICAgICAgICAgICAgICBzID0gKHMgKyAodGVtcFtpXVtrXSp0ZW1wW2tdW2pdKSVtb2QpJW1vZDsKICAgICAgICAgICAgcmVzW2ldW2pdID0gczsKICAgICAgICB9CiAgICB9CiAgICBpZiAocHdyJTIgPT0gMSkKICAgIHsKICAgICAgICBmb3IgKGkgPSAwOyBpIDwgcm93X251bTsgaSsrKQogICAgICAgIHsKICAgICAgICAgICAgZm9yIChqID0gMDsgaiA8IHJvd19udW07IGorKykKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgdGVtcFtpXVtqXSA9IHJlc1tpXVtqXTsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBmb3IgKGkgPSAwOyBpIDwgcm93X251bTsgaSsrKQogICAgICAgIHsKICAgICAgICAgICAgIGZvciAoaiA9IDA7IGogPCBjb2xfbnVtOyBqKyspCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIHMgPSAwOwogICAgICAgICAgICAgICAgZm9yIChrID0gMDsgayA8IGNvbF9udW07IGsrKykKICAgICAgICAgICAgICAgICAgICBzID0gKHMgKyAobWF0W2ldW2tdKih0ZW1wW2tdW2pdKSklbW9kKSVtb2Q7CiAgICAgICAgICAgICAgICByZXNbaV1bal0gPSBzOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgfQp9CgppbnQgbWFpbiAoKQp7CiAgICBtYXRbMF1bMF0gPSAyOwogICAgbWF0WzBdWzFdID0gMjsKICAgIG1hdFswXVsyXSA9IDM7CiAgICBtYXRbMV1bMF0gPSAyOwogICAgbWF0WzFdWzFdID0gMjsKICAgIG1hdFsxXVsyXSA9IDQ7CiAgICBtYXRbMl1bMF0gPSA1OwogICAgbWF0WzJdWzFdID0gNTsKICAgIG1hdFsyXVsyXSA9IDU7CiAgICBtb2QxPTEwMDA7Ly8gSm9kaSBtb2QgY29uc3RhbnQgbmEgaG9pCiAgICBtYXRwb3dlcig1KTsKICAgIGZvcihpbnQgaT0wO2k8bWF0X3NpemU7aSsrKQogICAgewogICAgICAgIGZvcihpbnQgaj0wO2o8bWF0X3NpemU7aisrKQogICAgICAgIHsKICAgICAgICAgICAgcHJpbnRmKCIlbGxkICAiLHJlc1tpXVtqXSk7CiAgICAgICAgfQogICAgICAgIHByaW50ZigiXG4iKTsKICAgIH0KICAgIHJldHVybiAwOwp9Cg==