def dice(i, o)
  a, b, c, d, e, f = i
  o == 'S' ? [e, a, c, d, f, b] : [d, b, a, f, e, c]
end

def check(a, b)
  r = []
  4.times do
    a = dice(a, 'E')
    c = a
    4.times do
      c = dice(c, 'S')
      p c
      return 'Yes' if c == b
    end
  end
  return 'No'
end

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