def f(x, y):
    return (4 * x + y + 1)%16

A = []
nx, ny = 0, 0
for i in range(4):
    A.append(list(map(int, input().split())))
    for j in range(4):
        if A[i][j] == 0:
            nx = i
            ny = j

dx = [0, 1, 0, -1]
dy = [1, 0, -1, 0]
for _ in range(16):
    for k in range(4):
        x, y = nx + dx[k], ny + dy[k]
        if x < 0 or x > 3 or y < 0 or y > 3:
            continue
        if A[x][y] != f(nx, ny):
            continue
        A[x][y], A[nx][ny] = A[nx][ny], A[x][y]
        nx, ny = x, y
        break

for i in range(4):
    for j in range(4):
        if A[i][j] != f(i, j):
            print("No")
            exit()
print("Yes")