
object Main extends App {

  override def main(args: Array[String]): Unit = {
    val str,str2 = io.StdIn.readLine.split(' ')

    val dice = new Dice(str(0), str(1), str(2), str(3), str(4), str(5))
    val dice2 = new Dice(str2(0), str2(1), str2(2), str2(3), str2(4), str2(5))
    
    val res = dice2.getAsTopAndSouthIs(dice.top, dice.south).exists(rot => rot == dice) 
    
    if(res) println("Yes")
    else println("No")
  }

  case class Dice(top: String, south: String, east: String, west: String, north: String, buttom: String) {

    def toNorth: Dice = {
      new Dice(south, buttom, east, west, top, north)
    }
    def toSouth: Dice = {
      new Dice(north, top, east, west, buttom, south)
    }
    def toEast: Dice = {
      new Dice(west, south, top, buttom, north, east)
    }
    def toWest: Dice = {
      new Dice(east, south, buttom, top, north, west)
    }
    def rotRight: Dice = {
      new Dice(top, east, north, south, west, buttom)
    }
    def rotLeft: Dice = {
      new Dice(top, west, south, north, east, buttom)
    }

    def getAsTop(toTop: String): Option[Dice] = toTop match {
        case str if str == top    => Option(this)
        case str if str == east   => Option(toWest)
        case str if str == west   => Option(toEast)
        case str if str == south  => Option(toNorth)
        case str if str == north  => Option(toSouth)
        case str if str == buttom => Option(toNorth.toNorth)
        case _ => Option.empty
  }

    def getAsSouthByRot(toSouth: String): Option[Dice] = toSouth match{
        case str if str == south => Option(this)
        case str if str == east  => Option(rotRight)
        case str if str == west  => Option(rotLeft)
        case str if str == north => Option(rotRight.rotRight)
        case _ => Option.empty
    }

    def getAsTopAndSouthIs(top: String, south: String): Option[Dice] = {      
      getAsTop(top).flatMap(_.getAsSouthByRot(south))
    }

  }

}