import scala.io.StdIn.readLine
import scala.collection.mutable.ArrayBuffer

case class Dice(var d:Seq[String]) {
  private val s = Array(4,0,2,3,5,1)
  private val w = Array(2,1,5,0,4,3)
  private val h = Array(0,2,4,1,3,5)
  private val buf = ArrayBuffer.empty[Seq[String]]

  def rotateAll() = {
    buf += d
    buf += s.map(d)
    buf += s.map(s).map(d)
    buf += s.map(s).map(s).map(d)
    buf += w.map(d)
    buf += w.map(w).map(w).map(d)

    buf += h.map(d)
    buf += s.map(s).map(s).map(h).map(d)
    buf += w.map(h).map(d)
    buf += w.map(w).map(w).map(h).map(d)
    buf += s.map(h).map(d)
    buf += s.map(s).map(h).map(d)

    buf += h.map(h).map(d)
    buf += s.map(s).map(s).map(h).map(h).map(d)
    buf += w.map(h).map(h).map(d)
    buf += w.map(w).map(w).map(h).map(h).map(d)
    buf += s.map(h).map(h).map(d)
    buf += s.map(s).map(h).map(h).map(d)

    buf += h.map(h).map(h).map(d)
    buf += s.map(s).map(s).map(h).map(h).map(h).map(d)
    buf += w.map(h).map(h).map(h).map(d)
    buf += w.map(w).map(w).map(h).map(h).map(h).map(d)
    buf += s.map(h).map(h).map(h).map(d)
    buf += s.map(s).map(h).map(h).map(h).map(d)
  }

  def getAllRot = buf.toArray
  def getFaces = d
}

object Main extends App {
  val faces1 = readLine.split(" ")
  val faces2 = readLine.split(" ").toSeq
  val dice1 = Dice(faces1)

  dice1.rotateAll()
  if(dice1.getAllRot.contains(faces2))
    println("Yes")
  else
    println("No")
}