table = {
  0 => [1, 3],
  1 => [5, 2],
  2 => [4, 0],
  3 => [5, 1],
  4 => [0, 3],
  5 => [4, 2]
}

d1 = gets.split
d2 = gets.split.map {|x| d1.index(x) }
a, b, c = d2[0..2]
puts ((table[a].include?(b) and c <= 2) or (!table[a].include?(b) and c >= 3)) ? "Yes" : "No"