import scala.io.StdIn.{readLine,readInt}
/**
  * AOJ
  */

object Main {

  def main(args: Array[String]): Unit = {

    var dice1 = read
    val dice2 = read

    for(side <- dice1){
      if(!dice2.contains(side)){println("No");return}
    }

    dice1 = findSide(dice2(4),4,"HHH",findSide(dice2(0),0,"WNNNW",dice1))
    println(
      dice1 match {
        case null => "No"
        case dice1 if((dice1 zip dice2).forall(x => x._1 == x._2)) => "Yes"
        case _ => "No"
      }
    )
  }

  def findSide(sideNum:Int, findSide:Int, searchCommands:String, dice:Array[Int]) : Array[Int] = {
    if(dice(findSide) == sideNum){return dice}
    var d = dice
    for(c <- searchCommands.toCharArray){
      d = getNextStatus(c,d)
      if(d(findSide) == sideNum){return d}
    }
    return null
  }

  def getNextStatus(cmd:Char,dice:Array[Int]): Array[Int] = cmd
    match {
      case 'N' => Array(dice(1),dice(5),dice(2),dice(3),dice(0),dice(4))
      case 'W' => Array(dice(2),dice(1),dice(5),dice(0),dice(4),dice(3))
      case 'H' => Array(dice(0),dice(3),dice(1),dice(4),dice(2),dice(5))
    }

  def read() : Array[Int] = {
    readLine().split(" ").map(_.toInt)
  }
}