object Main {
    def step(s: (Int, Int, Int), i: Char) = i match {
        case 'N' => (s._2, 5-s._1, s._3)
        case 'E' => (5-s._3, s._2, s._1)
        case 'L' => (s._1, s._3, 5-s._2)
        case 'R' => (s._1, 5-s._3, s._2)
    }
 
    def main(args: Array[String]) = {
        val in = io.Source.stdin.getLines.map(_.split(" ").map(_.toInt))
        val first = in.next
        val a = "NELNELNELNERNELNELNELNE".scanLeft((0, 1, 2))(step).map(x => List(x._1, x._2, x._3, 5-x._3, 5-x._2, 5-x._1).map(first(_)))
        if (a contains in.next.toList) println("Yes") else println("No")
    }
}