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() print "Yes"