package main import ( "bufio" "fmt" "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 } adj := false for _, pos := range ns { nI, nJ := i+pos[1], j+pos[0] if p[nI][nJ] == n { adj = true break } } if !adj { 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 n == 16 { continue } 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 }