#include using namespace std; #define rep(i, a, b) for(int i=a;i<(b);++i) #define all(x) begin(x), end(x) #define sz(x) (int)(x).size() typedef long long ll; typedef pair pii; typedef vector vi; int getcolsstate(int state, int m){ int colstate = state&1 + state&(1<sync_with_stdio(0); cout.tie(0); int n,m; cin>>n>>m; vector> mapa(2*n+1); for (int y=0;y<2*n+1;y++){ int lim = m; if (y%2){ lim++; } mapa[y].assign(lim,0); for (int x=0;x>val; mapa[y][x]=val; } } for (int y=0;y<2*n+1;y++){ int lim = m; if (y%2){ lim++; } mapa[y].assign(lim,0); for (int x=0;x>val; mapa[y][x]=mapa[y][x]^val; } } if (m>10){ vector> mapa2(2*m+1); for (int y=0;y<2*m+1;y++){ int lim = n; if (y%2){ lim++; } mapa2[y].assign(lim, 0); for (int x=0;x bitmapa(2*n+1,0); for (int y=0;y<2*n+1;y++){ int lim = m; if (y%2){ lim++; } for (int x=0;x states = {bitmapa[0], (~bitmapa[0])&mask}; for (int y=2;y<2*n+1;y+=2){ set setofstates; for (int state:states){ if (y<2*n){ int colstate = getcolsstate(state, m)^bitmapa[y-1]; vector nstates = {state^bitmapa[y], (~(state^bitmapa[y]))&mask}; for (int nstate:nstates){ int ncolstate = getcolsstate(nstate, m)^bitmapa[y+1]; if (ncolstate==colstate){ setofstates.insert(nstate); } } } else { if (state==bitmapa[y] || state == ((~bitmapa[y])&mask)){ setofstates.insert(state); } } } states.assign(all(setofstates)); } if (states.size()){ cout<<"Yes\n"; } else { cout<<"No\n"; } }