#include<bits/stdc++.h>
//#include<bits/extc++.h>
#define int long long
//#define int __int128
#define ull unsigned long long
#define MMST(x,y) memset(x,y,sizeof(x))
usingnamespacestd;//using namespace __gnu_pbds;
constintINF=0x3f3f3f3f;constintMOD=998244353;intread(){charc;intnum,f=1;while(c=(char)getchar(),!isdigit(c))if(c=='-')f=-1;num=(int)(c-'0');while(c=(char)getchar(),isdigit(c))num=num*10+(int)(c-'0');returnnum*f;}voidprt(intx){if(x<0){putchar('-');x=-x;}if(x>9)prt(x/10);putchar((char)(x%10+'0'));}intn,ans=1;inta[203][203],b[203][203];bitset<203>bit[203];voidinsert(bitset<203>x){for(inti=1;i<=n;i++)if(x[i]){if(!bit[i].count()){bit[i]=x;break;}x^=bit[i];}}voidwork(){cin>>n;for(inti=1;i<=n;i++)for(intj=1;j<=n;j++)cin>>a[i][j];for(inti=1;i<=n;i++)for(intj=1;j<=n;j++)cin>>b[i][j];for(intt=1;t<=n;t++){for(inti=1;i<=n;i++)bit[i]=0;for(inti=1;i<=n;i++){bitset<203>x=0;for(intj=1;j<=n;j++)x[j]=a[i][j];x[i]=x[i]^b[i][t];insert(x);}for(inti=1;i<=n;i++)if(!bit[i].count())ans=(ans<<1)%MOD;}cout<<ans<<endl;return;}signedmain(){intT=1;//read();
for(intCase=1;Case<=T;Case++){//printf("Case #%d: ",Case);
work();}return0;}