a = [map(int, raw_input().split()) for i in xrange(4)] for i in xrange(16): for y in xrange(4): for x in xrange(4): if a[y][x] - 1 == i: diff = abs(i % 4 - x) + abs(i / 4 - y) if diff > 1: print "No" exit() inv = 0 for i in xrange(16): if a[i/4][i%4] == 0: s = 3 - i % 4 + 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]: inv += 1 if (s + inv) % 2 == 0: print "Yes" else: print "No"