from collections import deque A = [list(map(int,input().split())) for _ in range(4)] correct = [[0] * 4 for _ in range(4)] for i in range(4): for j in range(4): if A[i][j] == 0: si, sj = i, j correct[i][j] = 4*i + j + 1 # 1マス分空きがある correct[-1][-1] = 0 directions=[ (1,0), (-1,0), (0,1), (0,-1), ] que = deque() que.append((si, sj)) while que: i, j = que.popleft() # 今いる場所に来るべき数値が上下左右にあれば移動する for di, dj in directions: ni = i + di nj = j + dj if not (0 <= ni < 4 and 0 <= nj < 4): # 範囲外ならスキップ continue if correct[i][j] == A[ni][nj]: # 今いる場所にあるべき数値が上下左右のどこかにある場合は入れ替える A[i][j], A[ni][nj] = A[ni][nj], A[i][j] # 0のマスをキューに追加 que.append((ni, nj)) # 可能な移動が全て完了したら最終チェック ans = True for i in range(4): for j in range(4): if correct[i][j] != A[i][j]: ans = False break if ans: print("Yes") else: print("No")