def check(x, y)
  return 'Yes' if x == y
  4.times do
    a, b, c, d, e, f  = x
    x = [e, a, c, d, f, b]
    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

  4.times do
    a, b, c, d, e, f  = x
    x = [d, b, a, f, e, c]
    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
  'No'
end

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