package main import ( "bufio" "fmt" "math" "os" "strconv" ) var sc = bufio.NewScanner(os.Stdin) func main() { sc.Split(bufio.ScanWords) p := make([][]int, 6) p[0] = []int{-1, -1, -1, -1, -1, -1} p[5] = []int{-1, -1, -1, -1, -1, -1} for i := 1; i < 5; i++ { p[i] = []int{-1, nextInt(), nextInt(), nextInt(), nextInt(), -1} } ns := [][2]int{{1, 0}, {0, 1}, {-1, 0}, {0, -1}, {0, 0}} for i := 1; i < 5; i++ { for j := 1; j < 5; j++ { n := (i-1)*4 + j if n == 16 { continue } initI, initJ := (p[i][j]-1)/4+1, (p[i][j]-1)%4+1 l := math.Abs(float64(i-initI)) + math.Abs(float64(j-initJ)) if l > 1 && p[i][j] != 0 { fmt.Println("No") return } for _, pos := range ns[:2] { if p[i+pos[1]][j+pos[0]] == -1 { continue } next := (n + (pos[1] * 4) + pos[0]) if p[i][j] == next && p[i+pos[1]][j+pos[0]] == n { fmt.Println("No") return } } } } fmt.Println("Yes") } func nextLine() string { sc.Scan() return sc.Text() } func nextInt() int { i, _ := strconv.Atoi(nextLine()) return i }