#include #define FOR(i,a,b) for(int i=(a);i<(b);i++) #define REP(i,b) FOR(i,0,b) #define PB push_back #define F first #define S second using namespace std; typedef long long LL; typedef LL ut; typedef vector VI; typedef pair pr; typedef pair ppr; typedef vector Vppr; typedef priority_queue > PQ; const int INF=1e+9; int ans[5][5],an[5][5]; int dx[]={0,0,1,-1},dy[]={1,-1,0,0}; int main(){ FOR(i,1,5) FOR(j,1,5) cin >> an[i][j]; int now=1; FOR(i,1,5) FOR(j,1,5) ans[i][j]=now++; ans[4][4]=0; REP(l,20){ FOR(i,1,5) FOR(j,1,5) REP(k,4) if(an[i][j]==0 && an[i+dy[k]][j+dx[k]]==ans[i][j]) swap(an[i][j],an[i+dy[k]][j+dx[k]]); } bool diff=false; FOR(i,1,5) FOR(j,1,5) if(an[i][j]!=ans[i][j]) diff=true; if(diff) cout << "No" << endl; else cout <<"Yes" << endl; }