import qualified Data.IntMap as M

groups = [[1,3,5,7,8,10,12], [4,6,9,11], [2]]

solve :: [Int] -> String
solve (a:b:_)
  | m M.! a == m M.! b = "Yes"
  | otherwise = "No"
  where
    m = M.fromList $ concatMap (\(i, l) -> map (\y -> (y,i)) l )$ zip [0..] groups

main = getContents >>= putStrLn.solve.map read.words.last.lines
