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