#include using namespace std; typedef signed long long ll; #define _P(...) (void)printf(__VA_ARGS__) #define FOR(x,to) for(x=0;x<(to);x++) #define FORR(x,arr) for(auto& x:arr) #define FORR2(x,y,arr) for(auto& [x,y]:arr) #define ALL(a) (a.begin()),(a.end()) #define ZERO(a) memset(a,0,sizeof(a)) #define MINUS(a) memset(a,0xff,sizeof(a)) template bool chmax(T &a, const T &b) { if(a bool chmin(T &a, const T &b) { if(a>b){a=b;return 1;}return 0;} //------------------------------------------------------- int A[8][8]; bitset<100000200> dp; int p10[9]; int B[10]; ll mask[10],NG; void solve() { int i,j,k,l,r,x,y; string s; p10[0]=1; FOR(i,8) p10[i+1]=p10[i]*10; FOR(y,8) { cin>>s; FOR(x,8) { A[y][x]=s[x]-'0'; B[y]+=A[y][x]*p10[x]; mask[y]|=(6LL+A[y][x])<<(5*x); } NG|=1LL<<(5*y+4); } dp[0]=1; queue Q; Q.push(0); while(Q.size()) { int cur=Q.front(); Q.pop(); int nex=cur/10+(cur%10)*10000000; if(dp[nex]==0) { dp[nex]=1; Q.push(nex); } ll V=0; FOR(i,8) V+=(1LL*cur/p10[i]%10)<<(5*i);; for(x=1;x<8;x++) { nex=cur+B[x]; ll V2=V+mask[x]; if((V2&NG)==0&&dp[nex]==0) { dp[nex]=1; Q.push(nex); } } } if(dp[B[0]]) { cout<<"Yes"<