#include using namespace std; #define ALL(x) (x).begin(), (x).end() #define REP(i, n) for(ll i=0; i<(ll)(n); i++) template bool chmax(T& a, T b) { return a bool chmin(T& a, T b) { return a>b ? a=b, true : false; } using ll=long long; const int INF=1e9+10; const ll INFL=4e18; using VI=vector; using VVI=vector; using VL=vector; using VVL=vector; using PL=pair; using VP=vector; using WG=vector>>; #ifdef LOCAL #include "./debug.hpp" #else #define debug(...) #define print_line #endif //---------------------------------------------------------- void solve() { ll N=8; VVI A(N,VI(N)); REP(i,N) { string s; cin>>s; REP(j,N) A[i][j]=s[j]-'0'; } vector> seen(N+1); queue> que; que.push({1,A[0]}); while(!que.empty()) { auto [idx,now]=que.front(); que.pop(); if(idx==N) { auto [a,b]=minmax_element(ALL(now)); if(*a==0 && *b==0) { puts("Yes"); return; } continue; } REP(i,N) { now.push_back(now[0]); now.erase(now.begin()); auto nxt=now; REP(j,N) nxt[j]-=A[idx][j]; if(!seen[idx+1].count(nxt)) { seen[idx+1].insert(nxt); que.push({idx+1,nxt}); } } } puts("No"); } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); //cout<>T; while(T--) solve(); }