#include <bits/stdc++.h>
#define each(i,a,b) for(int i=(a);i<=(b);++i)
#define eachr(i,a,b) for(int i=(a);i>=(b);--i)
using namespace std;
typedef long long ll;
const int N=625,p=998244353;
inline int rd(){
int w=1,r=0;char c=getchar();
while(!isdigit(c)) (c=='-')and(w=-1),c=getchar();
while(isdigit(c)) r=r*10+(c^48),c=getchar();
return r*w;
}
int n,p,a[N][N];
int det(){
int res=1;
each(i,1,n){
each(j,i+1,n){
while(a[i][i]){
int d=a[j][i]/a[i][i];
each(k,i,n) a[j][k]=(a[j][k]-1ll*d*a[i][k]%p+p)%p;
swap(a[i],a[j]),res*=-1;
}
swap(a[i],a[j]),res*=-1;
}
}
each(i,1,n) res=1ll*res*a[i][i]%p;
return (res+p)%p;
}
int main(){
n=rd();
each(i,1,n) each(j,1,n) a[i][j]=rd()%p;
printf("%d\n",det());
return 0;
}