object Main {
  def main(args: Array[String]): Unit = {
    val first  = Dice(io.StdIn.readLine().split(" ").map(_.toInt))
    val second = Dice(io.StdIn.readLine().split(" ").map(_.toInt))

    val answer =
      if (Dice.equals(first, second)) "Yes"
      else "No"

    println(answer)
  }

  case class Dice(upSide: Int, southSide: Int, eastSide: Int, westSide: Int, northSide: Int, downSide: Int) {
    import Direction._
    def spinClockwise: Dice = Dice(upSide, eastSide, northSide, southSide, westSide, downSide)
    def spinCounterclockwise: Dice = Dice(upSide, westSide, southSide, northSide, eastSide, downSide)
    def roll(direction: Direction): Dice = direction match {
      case North =>
        Dice(southSide, downSide, eastSide, westSide, upSide, northSide)
      case South =>
        Dice(northSide, upSide, eastSide, westSide, downSide, southSide)
      case West =>
        Dice(eastSide, southSide, downSide, upSide, northSide, westSide)
      case East =>
        Dice(westSide, southSide, upSide, downSide, northSide, eastSide)
    }
  }
  object Dice {
    def apply(sides: Array[Int]): Dice = Dice(sides(0), sides(1), sides(2), sides(3), sides(4), sides(5))

    def equals(d1: Dice, d2: Dice): Boolean = {
      import Direction._

      val sides = d1.northSide :: d1.westSide :: d1.southSide :: d1.eastSide ::
                  d1.northSide :: d1.westSide :: d1.southSide :: Nil
      @annotation.tailrec
      def sameDice(rolled: Option[Direction], d: Dice): Boolean = {
        val same =
          if (d1.upSide == d.upSide && d1.downSide == d.downSide) {
            sides.containsSlice(d.northSide :: d.westSide :: d.southSide :: d.eastSide :: Nil)
          } else if (d1.upSide == d.downSide && d1.downSide == d.upSide) {
            sides.containsSlice(d.northSide :: d.eastSide :: d.southSide :: d.westSide :: Nil)
          } else {
            false
          }
        if (same) {
          true
        } else {
          rolled match {
            case Some(North) => sameDice(Some(West), d.roll(North))
            case Some(West) => sameDice(None, d.roll(West))
            case _ => false
          }
        }
      }

      sameDice(Some(North), d2)
    }
  }

  sealed trait Direction
  object Direction {
    case object North extends Direction
    case object South extends Direction
    case object West extends Direction
    case object East extends Direction

    def apply(c: Char): Direction = c match {
      case 'N' => North
      case 'S' => South
      case 'E' => East
      case 'W' => West
      case _ => throw new Exception
    }
  }
}