Problem:
Three-Axis Views
A friend of yours is an artist designing Image-Containing Projection Cubes (ICPCs). An ICPC
is a crystal cube with its side of integer length. Some of its regions are made opaque through
an elaborate laser machining process. Each of the opaque regions is a cube of unit size aligned
with integer coordinates.
Figure A.1 depicts an ICPC as given in the Sample Input 1. Here, the green wires correspond
to the edges of the crystal cube. The blue small cubes correspond to the cubic opaque regions
inside the crystal.
Figure A.1. ICPC of Sample Input 1
ICPCs are meant to enjoy the silhouettes of its opaque regions projected by three parallel lights perpendicular to its faces. Figure A.2 depicts the ICPC and its three silhouettes.
Figure A.2. ICPC of Sample Input 1 and its silhouettes (dashed-dotted lines are the
edges of the parallel light perpendicular to the left face)
Your job is to write a program that decides whether there exists an ICPC that makes the given
silhouettes.
Input
The input consists of a single test case of the following format.
$n$
$s_1$
...
$s_n$
$t_1$
...
$t_n$
$u_1$
...
$u_n$
Here, $n$ is the size of the ICPC, an integer between 1 and 100, inclusive.
The ICPC of size $n$ makes three silhouettes of $n \times n$ squares of dark and bright cells. Cells are dark if they are covered by the shadows of opaque unit cubes, and are bright, otherwise. The $3n$ lines, each with $n$ digits, starting from the second line of the input denote the three silhouettes of the ICPC, where '0' represents a bright cell and '1' represents a dark cell. At least one of the digits in the $3n$ lines is '1'.
First comes the data for the silhouette on the $yz$-plane, where the first line $s_1$ gives the cells of the silhouettes with the largest $z$-coordinate value. They are in the order of their $y$-coordinates. The following lines, $s_2,..., s_n$, give the cells with the decreasing values of their $z$-coordinates.
Then comes the data for the silhouette on the $zx$-plane, where the first line, $t_1$ gives the cells with the largest $x$-coordinate value, in the order of their $z$-coordinates. The following lines, $t_2, ..., t_n$, give the cells with the decreasing values of their $x$-coordinates.
Finally comes the data for the silhouette on the $xy$-plane, where the first line, $u_1$, gives the cells with the largest $y$-coordinate value, in the order of their $x$-coordinates. The following lines, $u_2, ...,  u_n$, give the cells with the decreasing values of their $y$-coordinates.
The following figure depicts the three silhouettes of the ICPC given in the Sample Input 1.
Figure A.3. 0-1 representations of silhouettes (Sample Input 1)
Output
Print "Yes" if it is possible to make an ICPC with the given silhouettes. Print "No", otherwise.
Sample Input 1
3
010
010
111
100
111
101
011
111
010
Sample Output 1
Yes
Sample Input 2
2
00
01
00
10
10
00
Sample Output 2
Yes
Sample Input 3
2
00
00
00
10
10
00
Sample Output 3
No
Sample Input 4
2
01
00
00
10
10

...(truncated)

Submitted solutions:

code_snippet: #include<bits/stdc++.h>
// #include<atcoder/all>
// #include<boost/multiprecision/cpp_int.hpp>

using namespace std;
// using namespace atcoder;
// using bint = boost::multiprecision::cpp_int;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<ll>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using ve = vector<vector<int>>;
using vb = vector<bool>;
using vvb = vector<vb>;
#define rep(i,s,n) for(ll i = (ll)s;i < (ll)n;i++)
#define rrep(i,l,r) for(ll i = r-1;i >= l;i--)
#define ALL(x) (x).begin(),(x).end()
#define sz(c) ((ll)(c).size())
#define LB(A,x) (int)(lower_bound(A.begin(),A.end(),x)-A.begin())
#define UB(A,x) (int)(upper_bound(A.begin(),A.end(),x)-A.begin())
// #define MOD 1000000007
#define MOD 998244353
template<typename T>using min_priority_queue=priority_queue<T,vector<T>,greater<T>>;
template<typename T>ostream&operator<<(ostream&os,vector<T>&v){for(int i = 0;i < v.size();i++)os<<v[i]<<(i+1!=v.size()?" ":"");return os;}
template<typename T>istream&operator>>(istream&is,vector<T>&v){for(T&in:v)is>>in;return is;}
template<typename T1,typename T2>ostream&operator<<(ostream&os,pair<T1,T2>&p){os<<p.first<<" "<<p.second;return os;}
template<typename T1,typename T2>istream&operator>>(istream&is,pair<T1,T2>&p){is>>p.first>>p.second;return is;}
template<typename T> inline bool chmax(T &a,T b){if(a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a,T b){if(a > b){a = b;return true;}return false;}
ld dist(ld x1,ld y1,ld x2, ld y2){return sqrtl((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));}


int main(){
  
  ios_base::sync_with_stdio(0), cin.tie(0);
  int n;cin >> n;
  vector<string> s(n),t(n),u(n);
  cin >> s >> t >> u;
  vvvi is(n,vvi(n,vi(n)));
  rep(i,0,n)rep(j,0,n)rep(k,0,n){
    if(s[k][j] == '1')is[i][j][n-k-1]++;
    if(t[i][k] == '1')is[n-i-1][j][k]++;
    if(u[j][i] == '1')is[i][n-j-1][k]++;
  }
  vector<string> S(n,string(n,'0'));
  vector<string> T(n,string(n,'0'));
  vector<string> U(n,string(n,'0'));
  rep(i,0,n)rep(j,0,n)rep(k,0,n){
    if(is[i][j][k] >= 3){
      S[n-k-1][j] = '1';
      T[n-i-1][k] = '1';
      U[n-j-1][i] = '1';
    }
  }
  bool ok = true;
  rep(i,0,n){
    if(s[i] != S[i])ok = false;
    if(t[i] != T[i])ok = false;
    if(u[i] != U[i])ok = false;
  }
  cout << (ok ? "Yes\n" : "No\n");
  

  return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 11580
final_rank: 5

code_snippet: #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rrep(i,start,end) for (ll i = start;i >= (ll)(end);i--)
#define repn(i,end) for(ll i = 0; i <= (ll)(end); i++)
#define reps(i,start,end) for(ll i = start; i < (ll)(end); i++)
#define repsn(i,start,end) for(ll i = start; i <= (ll)(end); i++)
#define each(p,a) for(auto &p:a)
typedef vector<ll> vll;
typedef vector<pair<ll ,ll>> vpll;
typedef vector<vector<ll>> vvll;
typedef set<ll> sll;
typedef map<ll , ll> mpll;
typedef pair<ll ,ll> pll;
typedef tuple<ll , ll , ll> tpl3;
#define LL(...) ll __VA_ARGS__; input(__VA_ARGS__)
#define LD(...) ld __VA_ARGS__; input(__VA_ARGS__)
#define Str(...) string __VA_ARGS__; input(__VA_ARGS__)
#define Ch(...) char __VA_ARGS__; input(__VA_ARGS__)
#define all(a)  (a).begin(),(a).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define sz(x) (ll)x.size()
// << std::fixed << std::setprecision(10)
const ll INF = 1LL << 60;
const ld EPS = 1e-9;
 
ll lceil(ll a,ll b){if(a%b==0){return a/b;}if(a>=0){return (a/b)+1;}else{return -((-a)/b);}}
ll lfloor(ll a,ll b){if(a%b==0){return a/b;}if(a>=0){return (a/b);}else{return -((-a)/b)-1;}}
inline ll positive_mod(ll a,ll m){return (a % m + m)%m;}
inline ll popcnt(ull a){ return __builtin_popcountll(a);}
//0indexed
inline ll topbit(ll a){assert(a != 0);return 63 - __builtin_clzll(a);}
inline ll smlbit(ll a){assert(a != 0);return __builtin_ctzll(a);}
template<class T> bool chmin(T& a, T b){if(a > b){a = b;return true;}return false;}
template<class T> bool chmax(T& a, T b){if(a < b){a = b;return true;}return false;}
template<typename T> std::istream &operator>>(std::istream&is,std::vector<T>&v){for(T &in:v){is>>in;}return is;}
template<typename T> std::ostream &operator<<(std::ostream&os,const std::vector<T>&v){for(auto it=std::begin(v);it!=std::end(v);){os<<*it<<((++it)!=std::end(v)?" ":"");}return os;}
template<typename T1, typename T2>std::ostream &operator<< (std::ostream &os, std::pair<T1,T2> p){os << "{" << p.first << "," << p.second << "}";return os;}
template<class... T>void input(T&... a){(cin >> ... >> a);}
void print(){cout << endl;}
template<class T, class... Ts>void print(const T& a, const Ts&... b){cout << a;((cout << ' ' << b), ...);cout << endl;}
template<class T> void pspace(const T& a){ cout << a << ' ';}
void perr(){cerr << endl;}
template<class T, class... Ts>void perr(const T& a, const Ts&... b){cerr << a;((cerr << ' ' << b), ...);cerr << endl;}
void yes(bool i = true){ return print(i?"yes":"no"); }
void Yes(bool i = true){ return print(i?"Yes":"No"); }
void YES(bool i = true){ return print(i?"YES":"NO"); }
template <class T> vector<T> &operator++(vector<T> &v) {for(auto &e : v) e++;return v;}
template <class T> vector<T> operator++(vector<T> &v, signed) {auto res = v;for(auto &e : v) e++;return res;}
template <class T> vector<T> &operator--(vector<T> &v) {for(auto &e : v) e--;return v;}
template <class T> vector<T> operator--(vector<T> &v, signed) {auto res = v;for(auto &e : v) e--;return res;}
//grid探索用
vector<ll> _ta = {0,0,1,-1,1,1,-1,-1};
vector<ll> _yo = {1,-1,0,0,1,-1,1,-1};
bool isin(ll now_i,ll now_j,ll h,ll w){return (0<=now_i && now_i < h && 0 <= now_j && now_j < w);}
  
ll lpow(ll x,ll n){ll ans = 1;while(n >0){if(n & 1)ans *= x;x *= x;n >>= 1;}return ans;}
ll Modlpow(ll x,ll n,ll m){ll ans = 1;ll a = x%m;while(n >0){if(n & 1){ans *= a;ans%= m;}a *= a;a %= m;n >>= 1;}return ans;} 
const ll MOD9 = 998244353LL;
const ll MOD10 = 1000000007LL;
 
int main(){
  ios::sync_with_stdio(false);cin.tie(nullptr);
  LL(n);
  vector<vvll> g(3,vvll(n,vll(n)));
  rep(i,3){
    rep(j,n){
      Str(s);
      rep(k,n){
        if(s[k] == '1'){
          g[i][j][k] = 1;
        }
      }
    }
    reverse(all(g[i]));
  }
  // swap(g[1],g[2]);

  vector<vvll> v(n,vvll(n,vll(n)));
  rep(x,n)rep(y,n)rep(z,n){
    if(g[0][z][y] && g[1][x][z] && g[2][y][x]){
      v[x][y][z] = 1;
    }
  }
  //xを消す
  {
    vvll zy(n,vll(n));
    rep(x,n){
      rep(y,n)rep(z,n){
        if(v[x][y][z]) zy[z][y] = 1;
      }
    }
    if(zy != g[0]){
      cout << "No" << endl;
      return 0;
    }
  }
  {
    vvll xz(n,vll(n));
    rep(y,n){
      rep(x,n)rep(z,n){
        if(v[x][y][z])xz[x][z] = 1;
      }
    }
    if(xz != g[1]){
      cout << "No" << endl;
      return 0;
    }
  }

  {
    vvll yx(n,vll(n));
    rep(z,n){
      rep(x,n)rep(y,n){
        if(v[x][y][z])yx[y][x] = 1;
      }
    }
    if(yx != g[2]){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}
accuracy: 1
time_ms: 10
memory_kb: 11904
final_rank: 6

code_snippet: #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vl vector<ll>
#define ov4(a, b, c, d, name, ...) name
#define rep3(i, a, b, c) for(ll i = (a); i < (b); i += (c))
#define rep2(i, a, b) rep3(i, a, b, 1)
#define rep1(i, n) rep2(i, 0, n)
#define rep0(n) rep1(aaaaa, n)
#define rep(...) ov4(__VA_ARGS__, rep3, rep2, rep1, rep0)(__VA_ARGS__)
#define per(i, a, b) for(ll i = (a)-1; i >= (b); i--)
#define fore(e, v) for(auto&& e : v)
#define all(a) begin(a), end(a)
#define si(a) (int)(size(a))
#define lb(v, x) (lower_bound(all(v), x) - begin(v))
#define eb emplace_back

template<typename T, typename S> bool chmin(T& a, const S& b) { return a > b ? a = b, 1 : 0; }
template<typename T, typename S> bool chmax(T& a, const S& b) { return a < b ? a = b, 1 : 0; }

const int INF = 1e9 + 100;
const ll INFL = 3e18 + 100;

#define i128 __int128_t

struct _ {
    _() { cin.tie(0)->sync_with_stdio(0), cout.tie(0); }
} __;

int main() {
    ll N;
    cin >> N;
    using vs = vector<string>;
    vs S(N), T(N), U(N);
    rep(i, N) cin >> S[i];
    rep(i, N) cin >> T[i];
    rep(i, N) cin >> U[i];
    reverse(all(S));
    reverse(all(T));
    reverse(all(U));

    using vb = vector<bool>;
    using vvb = vector<vb>;
    using vvvb = vector<vvb>;
    vvvb exist(N, vvb(N, vb(N, true)));
    rep(i, N) {
        rep(j, N) {
            rep(k, N) {
                exist[i][j][k] = exist[i][j][k] && (S[k][j] == '1');
                exist[i][j][k] = exist[i][j][k] && (T[i][k] == '1');
                exist[i][j][k] = exist[i][j][k] && (U[j][i] == '1');
            }
        }
    }
    
    string init(N, '0');
    vs nS(N, init), nT(N, init), nU(N, init);
    rep(i, N) {
        rep(j, N) {
            rep(k, N) {
                // cout << exist[i][j][k];
                if (exist[i][j][k]) {
                    nS[k][j] = '1';
                    nT[i][k] = '1';
                    nU[j][i] = '1';
                }
            }
            // cout << "\n";
        }
        // cout << "\n";
    }
    // rep(i, N) cout << nS[i] << "\n";
    // rep(i, N) cout << nT[i] << "\n";
    // rep(i, N) cout << nU[i] << "\n";
    bool ans = S == nS;
    ans &= T == nT;
    ans &= U == nU;
    cout << (ans ? "Yes" : "No") << "\n";
}
accuracy: 1
time_ms: 10
memory_kb: 4352
final_rank: 3

code_snippet: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define rep(i, n) for (ll i = 0; i < (ll) (n); i++)

int main() {
    int N;
    cin>>N;
    vector<string> X(N),Y(N),Z(N);
    rep(i,N)cin>>X[i];
    rep(i,N)cin>>Y[i];
    rep(i,N)cin>>Z[i];
    vector<vector<vector<int>>> D(N,vector<vector<int>>(N,vector<int>(N,0)));
    rep(i,N)rep(j,N)rep(k,N){
        if(X[N-k-1][j]=='1'&&Y[N-i-1][k]=='1'&&Z[N-j-1][i]=='1')D[i][j][k]=1;
    }
    vector<vector<int>> U(N,vector<int>(N,0)),V(N,vector<int>(N,0)),W(N,vector<int>(N,0));
    rep(k,N)rep(i,N)rep(j,N)if(D[i][j][k]==1){
        U[N-k-1][j]=1;
        V[N-i-1][k]=1;
        W[N-j-1][i]=1;
    }
    bool OK=1;
    rep(i,N)rep(j,N){
        if(U[i][j]!=X[i][j]-'0')OK=0;
        if(V[i][j]!=Y[i][j]-'0')OK=0;
        if(W[i][j]!=Z[i][j]-'0')OK=0;
    }
    cout<<(OK?"Yes":"No")<<endl;
    

}
accuracy: 1
time_ms: 10
memory_kb: 7844
final_rank: 4

code_snippet: #include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
using ll=long long;
#define all(p) p.begin(),p.end()
int main(){
    int N;
    cin>>N;
    vector p(N,vector(N,vector<int>(N)));
    vector r(3,vector(N,vector<int>(N)));
    vector q(3,vector(N,vector<int>(N)));
    rep(rprp,0,3){
        rep(i,0,N) rep(j,0,N){
            char c;
            cin>>c;
            r[rprp][j][N-1-i]=c-'0';
        }
        rep(i,0,N) rep(j,0,N){
            if(r[rprp][i][j]) rep(k,0,N) p[k][i][j]++;
        }
        auto tmp=p;
        rep(i,0,N) rep(j,0,N) rep(k,0,N){
            tmp[j][k][i]=p[i][j][k];
        }
        swap(tmp,p);
    }
    rep(i,0,N) rep(j,0,N) rep(k,0,N){
        if(p[i][j][k]==3){
            q[0][j][k]=1;
            q[1][k][i]=1;
            q[2][i][j]=1;
        }
    }
    cout<<(q==r?"Yes\n":"No\n");
}
accuracy: 1
time_ms: 10
memory_kb: 12072
final_rank: 7

code_snippet: #include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i = 0; i < n; i++)
#define all(a) (a).begin(),(a).end()


int main(){
    ll n;
    cin >> n;
    vector<string> a(n);
    vector<string> b(n);
    vector<string> c(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    for(int i=0;i<n;i++){
        cin >> b[i];
    }
    for(int i=0;i<n;i++){
        cin >> c[i];
    }
    reverse(a.begin(),a.end());
    reverse(b.begin(),b.end());
    reverse(c.begin(),c.end());
    vector<vector<vector<bool>>> z(n,vector<vector<bool>>(n,vector<bool>(n,false)));
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            for(int k=0;k<n;k++){
                if(a[k][j]=='1'&&b[i][k]=='1'&&c[j][i]=='1')z[i][j][k]=true;
            }
        }
    }
    string ans="Yes";
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            ll aa=0;
            ll bb=0;
            ll cc=0;
            for(int k=0;k<n;k++){
                if(z[k][j][i])aa++;
                if(z[i][k][j])bb++;
                if(z[j][i][k])cc++;
            }
            if(aa==0&&a[i][j]=='1')ans="No";
            if(bb==0&&b[i][j]=='1')ans="No";
            if(cc==0&&c[i][j]=='1')ans="No";

        }
        
    }
    cout << ans << endl;
}
accuracy: 1
time_ms: 10
memory_kb: 4200
final_rank: 1

code_snippet: #include <bits/stdc++.h>
using namespace std;
#define int long long
#define INF 1e18
#define Rep(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define all(x) (x).begin(), (x).end()
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;
//const int mod = 998244353;
const double pi = 3.1415926535897932;

int n;
int f[110][110][110];
int yz[110][110], zx[110][110], xy[110][110];

signed main(){
    cout << fixed << setprecision(18);

    cin >> n;
    for(int j = n-1; j >= 0; j--){
        string s;
        cin >> s;
        rep(i, n)yz[i][j] = s[i] - '0';
    }
    for(int j = n-1; j >= 0; j--){
        string s;
        cin >> s;
        rep(i, n)zx[i][j] = s[i] - '0';
    }
    for(int j = n-1; j >= 0; j--){
        string s;
        cin >> s;
        rep(i, n)xy[i][j] = s[i] - '0';
    }

    rep(i, n)rep(j, n)rep(k, n)f[i][j][k] = 1;

    //yz
    rep(j, n)rep(k, n){
        if(yz[j][k] == 0){
            rep(i, n){
                if(f[i][j][k] == 2){
                    cout << "No" << endl;
                    return 0;
                }
                f[i][j][k] = 0;
            }
        }
        else{
            int cnt = n;//ブロックを置ける場所の数
            rep(i, n)if(f[i][j][k] == 0)cnt--;
            if(cnt == 0){
                cout << "No" << endl;
                return 0;
            }
            if(cnt == 1){
                rep(i, n)if(f[i][j][k] == 1)f[i][j][k] = 2;
            }
        }
    }
    //zx
    rep(k, n)rep(i, n){
        if(zx[k][i] == 0){
            rep(j, n){
                if(f[i][j][k] == 2){
                    cout << "No" << endl;
                    return 0;
                }
                f[i][j][k] = 0;
            }
        }
        else{
            int cnt = n;
            rep(j, n)if(f[i][j][k] == 0)cnt--;
            if(cnt == 0){
                cout << "No" << endl;
                return 0;
            }
            if(cnt == 1){
                rep(j, n)if(f[i][j][k] == 1)f[i][j][k] = 2;
            }
        }
    }
    //xy
    rep(i, n)rep(j, n){
        if(xy[i][j] == 0){
            rep(k, n){
                if(f[i][j][k] == 2){
                    cout << "No" << endl;
                    return 0;
                }
                f[i][j][k] = 0;
            }
        }
        else{
            int cnt = n;
            rep(k, n)if(f[i][j][k] == 0)cnt--;
            if(cnt == 0){
                cout << "No" << endl;
                return 0;
            }
            if(cnt == 1){
                rep(k, n)if(f[i][j][k] == 1)f[i][j][k] = 2;
            }
        }
    }

    //yz
    rep(j, n)rep(k, n){
        if(yz[j][k] == 0){
            rep(i, n){
                if(f[i][j][k] == 2){
                    cout << "No" << endl;
                    return 0;
                }
                f[i][j][k] = 0;
            }
        }
        else{
            int cnt = n;//ブロックを置ける場所の数
            rep(i, n)if(f[i][j][k] == 0)cnt--;
            if(cnt == 0){
                cout << "No" << endl;
                return 0;
            }
            if(cnt == 1){
                rep(i, n)if(f[i][j][k] == 1)f[i][j][k] = 2;
            }
        }
    }
    //zx
    rep(k, n)rep(i, n){
        if(zx[k][i] == 0){
            rep(j, n){
                if(f[i][j][k] == 2){
                    cout << "No" << endl;
                    return 0;
                }
                f[i][j][k] = 0;
            }
        }
        else{
            int cnt = n;
            rep(j, n)if(f[i][j][k] == 0)cnt--;
            if(cnt == 0){
                cout << "No" << endl;
                return 0;
            }
            if(cnt == 1){
                rep(j, n)if(f[i][j][k] == 1)f[i][j][k] = 2;
            }
        }
    }
    //xy
    rep(i, n)rep(j, n){
        if(xy[i][j] == 0){
            rep(k, n){
                if(f[i][j][k] == 2){
                    cout << "No" << endl;
                    return 0;
                }
                f[i][j][k] = 0;
            }
        }
        else{
            int cnt = n;
            rep(k, n)if(f[i][j][k] == 0)cnt--;
            if(cnt == 0){
                cout << "No" << endl;
                return 0;
            }
            if(cnt == 1){
                rep(k, n)if(f[i][j][k] == 1)f[i][j][k] = 2;
            }
        }
    }

    cout << "Yes" << endl;
    

}
accuracy: 1
time_ms: 10
memory_kb: 13508
final_rank: 8

code_snippet: #pragma GCC optimize("Ofast")
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cstdio>
#include <ctime>
#include <assert.h>
#include <chrono>
#include <random>
#include <numeric>
#include <set>
#include <deque>
#include <stack>
#include <sstream>
#include <utility>
#include <cstring>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <array>
#include <bitset>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
    return (ull)rng() % B;
}
inline ll time() {
    return static_cast<long double>(chrono::duration_cast<chrono::nanoseconds>(chrono::steady_clock::now().time_since_epoch()).count()) * 1e-9;
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<vector<vector<bool>>> box(n,vector<vector<bool>>(n,vector<bool>(n)));
    vector<string> s(n),t(n),r(n);
    for(int i=0;i<n;i++){
        cin >> s[i];
    }
    for(int i=0;i<n;i++){
        cin >> t[i];
    }
    for(int i=0;i<n;i++){
        cin >> r[i];
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            for(int k=0;k<n;k++){
                if(s[n-1-k][j] == '1' and t[n-1-i][k] == '1' and r[n-1-j][i] == '1'){
                    box[i][j][k] = true;
                }
            }
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            for(int k=0;k<n;k++){
                if(box[i][j][k]){
                    s[n-1-k][j] = '0';
                    t[n-1-i][k] = '0';
                    r[n-1-j][i] = '0';
                }
            }
        }
    }
    bool ok = true;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(s[i][j] == '1' or t[i][j] == '1' or r[i][j] == '1'){
                ok = false;
            }
        }
    }
    if(ok){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}
accuracy: 1
time_ms: 10
memory_kb: 4220
final_rank: 2