import java.io.BufferedReader; import java.io.InputStreamReader; public class No278 { public static void main(String[] args) { try { int goal[][] = { { 1, 2, 3, 4 }, { 5, 6, 7, 8 }, { 9, 10, 11, 12 }, { 13, 14, 15, 0 } }; BufferedReader br = new BufferedReader(new InputStreamReader( System.in)); int start[][] = new int[4][4]; for (int i = 0; i < 4; i++) { start[i] = strToIntArray(br.readLine()); } String str = "Yes"; for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { for (int j2 = 0; j2 < 4; j2++) { for (int k = 0; k < 4; k++) { // 距離が2以上離れてたらむりだろ if (goal[i][j] == start[j2][k]) { if (1 < Math.abs(i - j2) + Math.abs(j - k)) { str = "No"; } } } } } } System.out.println(str); } catch (Exception e) { e.printStackTrace(); System.err.println("Error:" + e.getMessage()); } } static int[] strToIntArray(String S) { String[] strArray = S.split(" "); int[] intArray = new int[strArray.length]; for (int i = 0; i < strArray.length; i++) { intArray[i] = Integer.parseInt(strArray[i]); } return intArray; } }