# -*- coding:utf-8 -*- def solve(): global board,ans,isMoved for i in xrange(4): if 0 in board[i]: y = i x = board[i].index(0) if x + 1 < 4: if board[y][x+1] == ans[y][x] and isMoved[y][x+1] == False: board[y][x],board[y][x+1] = board[y][x+1],board[y][x] isMoved[y][x+1] = True return True if x - 1 >= 0: if board[y][x-1] == ans[y][x]and isMoved[y][x-1] == False: board[y][x],board[y][x-1] = board[y][x-1],board[y][x] isMoved[y][x-1] = True return True if y + 1 < 4: if board[y+1][x] == ans[y][x]and isMoved[y+1][x] == False: board[y][x],board[y+1][x] = board[y+1][x],board[y][x] isMoved[y+1][x] = True return True if y - 1 >= 0: if board[y-1][x] == ans[y][x]and isMoved[y-1][x] == False: board[y][x],board[y-1][x] = board[y-1][x],board[y][x] isMoved[y-1][x] = True return True return False if __name__ == "__main__": ans = [[1,2,3,4],[5,6,7,8],[9,10,11,12],[13,14,15,0]] isMoved = [[False for i in xrange(4)]for i in xrange(4)] board = [[]for i in xrange(4)] for i in xrange(4): board[i] = map(int,raw_input().split()) i = 0 while board != ans and i < 16: if solve() == False: print "No" exit() i += 1 if ans == board: print "Yes" else: print "No"