/**
高斯消元矩阵求逆
**/
#include <cstdio>
#include <stack>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <iostream>
#include <map>
#include <vector>
#include <queue>
#include <set>
#define eps 1e-8
typedef long long ll;
const double PI = acos(-1.0);
const int maxn = 1005;
const int INF = 0x3f3f3f;
const ll mod = 1e9+7;
const ll linf = 0x3f3f3f3f3f3f3f3f;
using namespace std;
int n,m;
ll f[maxn][maxn];
ll r,ret;
ll ksm(ll a, ll b)//求逆元
{
ret = 1;
while(b)
{
if(b&1)
ret = ret*a%mod;
a = a*a%mod;
b >>= 1;
}
return ret;
}
int main()
{
scanf("%d",&n);
m = n*2;
for(int i = 1; i<=n; i++)
{
for(int j = 1; j<=n; j++)
{
scanf("%lld",&f[i][j]);
}
f[i][n+i] = 1;
}
//高斯消元模板
for(int i = 1; i<=n; i++)
{
for(int j = i; j<=n; j++)
{
//找到xi的系数不为0的一个方程
if(f[j][i])
{
for(int k = 1; k<=m; k++)
swap(f[i][k],f[j][k]);
break;
}
}
if(!f[i][i])
{
cout<<"No Solution"<<endl;
return 0;
}
r = ksm(f[i][i],mod-2);
//将该方程的xi的系数变为1
for(int j = i; j<=m; j++)
f[i][j] = f[i][j]*r%mod;
//消去其他方程的xi的系数
for(int j = 1; j<=n; j++)
{
if(j != i)
{
for(int k = i; k<=m; k++)
f[j][k] = (f[j][k] - f[j][i]*f[i][k]%mod + mod)%mod;
}
}
}
for(int i = 1; i<=n; i++)
{
for(int j = n+1; j<=m; j++)
cout<<f[i][j]<<" ";
cout<<endl;
}
return 0;
}