#include using namespace std; using ll = long long; int main(){ ios::sync_with_stdio(false); cin.tie(0); vector A(8); for(auto &&str : A) cin >> str; string str(8, '0'); constexpr int mx = 2097152; for(int S = 0; S < mx; S++){ fill(str.begin(), str.end(), '0'); for(int j = 1, sh, tmp = S; j < 8; j++, tmp /= 8){ sh = tmp % 8; for(int k = 0; k < 8; k++){ str[k] = min(str[k] + (int)(A[j][(k + sh) % 8] - '0'), (int)':'); } } if(str == A[0]){ cout << "Yes\n"; return 0; } } cout << "No\n"; }