#include using namespace std; random_device rnd; mt19937 mt(rnd()); int main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); vector name(300000); iota(name.begin(),name.end(),0); auto check = [&](int n,vector P) -> bool { for(auto &p : P) p = name.at(p); int d1 = 0,d2 = 0; for(int i=0; i already(n*n); for(int i=0; i> N; vector A(N*N); for(auto &a : A) cin >> a; if(N <= 3){ vector P(N*N); iota(P.begin(),P.end(),0); map> M; do{ if(check(N,P) == false) continue; long long now = 0; for(int i=0; i P; for(int i=0; i<4; i++) for(int k=0; k<4; k++) name.at(i*N+k) = i*4+k,P.push_back(i*N+k); map> M; while(true){ shuffle(P.begin(),P.end(),mt); if(check(4,P) == false) continue; long long now = 0; for(int i=0; i<16; i++) now += A.at(i/4*N+i%4)*P.at(i); if(M.count(now)){ cout << "Yes\n"; for(int i=0; i