
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): List[Dice] =  List(
        if (top == toTop) List(this) else List.empty,
        if (south == toTop) List(toNorth) else List.empty,
        if (north == toTop) List(toSouth) else List.empty,
        if (west == toTop) List(toEast) else List.empty,
        if (east == toTop) List(toWest) else List.empty,
        if (buttom == toTop) List(toEast.toEast) else List.empty
        ).flatten

    def getAsSouthByRot(toSouth: String): List[Dice] = List(
        if (south == toSouth) List(this) else List.empty,
        if (north == toSouth) List(rotLeft.rotLeft) else List.empty,
        if (west == toSouth) List(rotLeft) else List.empty,
        if (east == toSouth) List(rotRight) else List.empty
        ).flatten

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

  }

}