def check(x, y)
  return 'Yes' if x == y
  2.times do |z|
    4.times do
      a, b, c, d, e, f = x
      x = z.zero? ? [e, a, c, d, f, b] : [a, c, e, b, d, f]
      return 'Yes' if x == y
      c = x
      4.times do
        i, j, k, l, m, n = c
        c = [i, k, m, j, l, n]
        return 'Yes' if c == y
      end
    end
  end
  'No'
end

puts check(*$<.map(&:chomp).map(&:split))