object Main {
  def main(args: Array[String]): Unit = {
    val numbers = io.StdIn.readLine().split(" ")
    val other = io.StdIn.readLine().split(" ")

    if (same(numbers, other)) {
      println("Yes")
    } else {
      println("No")
    }
  }

  def same(src: Array[String], target: Array[String]): Boolean = {
    def get1265(arr: Array[String]): String = Array(arr(0), arr(1), arr(5), arr(4)).mkString(" ")
    def get2354(arr: Array[String]): String = Array(arr(1), arr(2), arr(4), arr(3)).mkString(" ")
    def get1364(arr: Array[String]): String = Array(arr(0), arr(2), arr(5), arr(3)).mkString(" ")
    def contains(src: String, target: String): Boolean = s"$src $src".contains(target)

    if (src sameElements target) {
      true
    } else {
      val sLine1 = get1265(src)
      val sLine2 = get2354(src)
      val sLine3 = get1364(src)

      val tLine1 = get1265(target)
      val tLine2 = get2354(target)
      val tLine3 = get1364(target)

      if (contains(sLine1, tLine1)) {
        contains(sLine2, tLine2.reverse) && contains(sLine3, tLine3.reverse)
      } else if (contains(sLine2, tLine2)) {
        contains(sLine1, tLine1.reverse) && contains(sLine3, tLine3.reverse)
      } else if (contains(sLine3, tLine3)) {
        contains(sLine1, tLine1.reverse) && contains(sLine2, tLine2.reverse)
      } else {
        false
      }
    }
  }
}