# -*- coding: utf-8 -*- import sys,copy,math,heapq,itertools as it,fractions,re,bisect,collections as coll r = {i + 1:(i%4, i/4) for i in xrange(15)} a = [map(int, raw_input().split()) for i in xrange(4)] for y in xrange(4): for x in xrange(4): if a[y][x] == 0: continue xx, yy = r[a[y][x]] if abs(xx - x) + abs(yy - y) > 1: print "No" exit() t = 0 for i in xrange(16): if a[i/4][i%4] == 0: t += abs(3 - i%4) + abs(3 - i/4) continue for j in xrange(i + 1, 16): if a[j/4][j%4] == 0: continue if a[i/4][i%4] > a[j/4][j%4]: t += 1 print "Yes" if t%2 == 0 else "No"