def check(B): return all(B[i] == i for i in range(16)) def solve(B): z = B.index(0) B[z] = 16 B = [n - 1 for n in B] while not check(B): if z > 3: if B[z - 4] == z: B[z], B[z - 4] = B[z - 4], B[z] z -= 4 continue if z % 4 != 0: if B[z - 1] == z: B[z], B[z - 1] = B[z - 1], B[z] z -= 1 continue if z % 4 != 3: if B[z + 1] == z: B[z], B[z + 1] = B[z + 1], B[z] z += 1 continue if z < 12: if B[z + 4] == z: B[z], B[z + 4] = B[z + 4], B[z] z += 4 continue print('No') return print('Yes') def main(): A = [] for i in range(4): A.extend(list(map(int, input().split()))) solve(A) if __name__ == '__main__': main()