import java.util.*; public class Main{ public static void main(String[] args)throws Exception{ new Main().solve(); } static int[] dx={1,-1,0,0}; static int[] dy={0,0,1,-1}; void solve(){ Scanner sc=new Scanner(System.in); int[][] table=new int[4][4]; int sx=-1; int sy=-1; for(int i=0;i<4;i++){ for(int j=0;j<4;j++){ table[i][j]=sc.nextInt(); if(table[i][j]==0){ sx=j; sy=i; } } } for(int i=0;!check(table)&&i<16;i++){ for(int j=0;j<4;j++){ int x=sx+dx[j]; int y=sy+dy[j]; if(0>x||0>y||x>=4||y>=4)continue; if(table[y][x]==4*sy+sx+1){ int dumsXsY=table[sy][sx]; table[sy][sx]=table[y][x]; table[y][x]=dumsXsY; sx=x; sy=y; break; } } } if(check(table)){ System.out.println("Yes"); }else{ System.out.println("No"); } } boolean check(int[][] table){ for(int i=0;i<4;i++){ for(int j=0;j<4;j++){ if(table[i][j]!=4*i+j+1&&!(i==3&&j==3&&table[i][j]==0)){ return false; } } } return true; } void tr(Object...o){System.out.println(Arrays.deepToString(o));} }