t = [list(map(int, input().split())) for i in range(4)] f = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 0]] d = [[(0, 0) for j in range(4)] for i in range(4)] def solve(i, j): if j-1 >= 0 and d[i][j-1] == (0, -1): d[i][j-1] = (0, 0) return solve(i, j-1) if j+1 < 4 and d[i][j+1] == (0, 1): d[i][j+1] = (0, 0) return solve(i, j+1) if i-1 >= 0 and d[i-1][j] == (-1, 0): d[i-1][j] = (0, 0) return solve(i-1, j) if i+1 < 4 and d[i+1][j] == (1, 0): d[i+1][j] = (0, 0) return solve(i+1, j) return i, j def main(): flg, p = True, (0, 0) for i in range(4): for j in range(4): if f[i][j] == 0: p = (i, j) continue for k in range(4): for l in range(4): if f[i][j] == t[k][l]: d[i][j] = (i-k, j-l) if abs(d[i][j][0]) + abs(d[i][j][1]) > 1: flg = False pb = solve(3, 3) if t[pb[0]][pb[1]] != 0: flg = False for i in range(4): for j in range(4): if d[i][j] != (0, 0): flg = False if flg: print("Yes") else: print("No") if __name__ == '__main__': main()