#include using namespace std; typedef long long ll; typedef pair pll; typedef long double ld; typedef pair pdd; #define vec vector #define For(i, a, n) for(ll i=(ll)a;i pairoperator+(const pair&a, const pair&b){ return {a.first + b.first, a.second + b.second}; } template ostream&operator<<(ostream&os, const pair&c){ return os<<"("< basic_ostream&operator<<(basic_ostream&os, const C&c){ for(auto itr=begin(c);itr!=end(c);++itr){ os<<(itr==begin(c)?"":" ")<<*itr; } return os; } template void dbg(Args&&...args){ ((cerr<>N>>M; vec> b(2*N+1); For(i,0, 2*N+1){ ll neparny = i%2; For(j, 0, N+neparny){ ll x;cin>>x; b[i].push_back(x); } } // dbg("b");for(auto i:b)dbg(i); const int bsz = 500; vec> mat; For(i,0, 2*N+1){ ll neparny = i%2; For(j, 0, N+neparny){ bitset add = 0; ll a;cin>>a; if(neparny){ add[getIdCiara(-1, j)] = 1; if(j=0)add[getIdStvorec(i/2, j-1)] = 1; } else{ add[getIdCiara(i/2, -1)] = 1; if(i<2*N)add[getIdStvorec(i/2, j)] = 1; if(i/2 - 1 >=0){ add[getIdStvorec(i/2-1, j)] = 1; } } add[bsz-1] = a!=b[i][j]; // dbg(i, j, a, b[i][j], (ll)a!=b[i][j], add); mat.push_back(add); } } // dbg("mat"); // for(auto i: mat){ // For(j, 0, sz(i))cerr<<(ll)i[j]; // cerr< vis(sz(mat)); For(pos, 0, bsz-1){ ll x= -1; For(i, 0,sz(mat)){ if(mat[i][pos] && !vis[i]){ x = i; break; } } if(x == -1)continue; vis[x] = 1; For(i, 0, sz(mat)){ if(i!=x)if(mat[i][pos])mat[i]^=mat[x]; } } // dbg("mat"); // for(auto i: mat){ // For(j, 0, sz(i))cerr<<(ll)i[j]; // cerr<sync_with_stdio(0); cin.exceptions(cin.failbit); int t = 1; while(t--)solve(); return 0; }