use std::io::*;
use std::str::FromStr;

#[allow(unused_macros)]
macro_rules! scan {
  ($e:expr; $t:ty) => {
    $e.get::<$t>()
  };
  ($e:expr; $($t:ty), *) => {
    ($($e.get::<$t>(),)*)
  }
}

struct Scanner<R: BufRead> {
  reader: R,
  iter: std::vec::IntoIter<String>
}

#[allow(dead_code)]
impl<R: BufRead> Scanner<R> {
  fn new(reader: R) -> Scanner<R> {
    Scanner { reader, iter: vec![String::new()].into_iter() }
  }
  fn new_line(&mut self) {
    let mut line = String::new();
    self.reader.read_line(&mut line).ok();
    self.iter = line.trim().split_whitespace().map(|s| s.to_string()).collect::<Vec<String>>().into_iter();
  }
  fn get<T: FromStr>(&mut self) -> T {
    self.iter.next().unwrap().parse().ok().unwrap()
  }
  fn get_as_vec<T: FromStr>(&mut self) -> Vec<T> {
    self.iter.clone().map(|v| v.parse().ok().unwrap()).collect()
  }
  fn get_line(&mut self) -> String {
    let mut line = String::new();
    self.reader.read_line(&mut line).ok();
    line.trim().to_string()
  }
}

struct Dice {
  label: Vec<i32>,
}

#[allow(dead_code)]
impl Dice {
  fn new(dice: Vec<i32>) -> Dice {
    Dice { label: dice }
  }
  fn top(&self) -> i32 {
    self.label[0]
  }
  fn front(&self) -> i32 {
    self.label[1]
  }
  fn right(&self) -> i32 {
    self.label[2]
  }
  fn east(&mut self) {
    let tmp = self.label[0];
    self.label[0] = self.label[3];
    self.label[3] = self.label[5];
    self.label[5] = self.label[2];
    self.label[2] = tmp;
  }
  fn west(&mut self) {
    let tmp = self.label[0];
    self.label[0] = self.label[2];
    self.label[2] = self.label[5];
    self.label[5] = self.label[3];
    self.label[3] = tmp;
  }
  fn north(&mut self) {
    let tmp = self.label[0];
    self.label[0] = self.label[1];
    self.label[1] = self.label[5];
    self.label[5] = self.label[4];
    self.label[4] = tmp;
  }
  fn south(&mut self) {
    let tmp = self.label[0];
    self.label[0] = self.label[4];
    self.label[4] = self.label[5];
    self.label[5] = self.label[1];
    self.label[1] = tmp;
  }
  fn rot_right(&mut self) {
    let tmp = self.label[1];
    self.label[1] = self.label[3];
    self.label[3] = self.label[4];
    self.label[4] = self.label[2];
    self.label[2] = tmp;
  }
  fn rot_left(&mut self) {
    let tmp = self.label[1];
    self.label[1] = self.label[2];
    self.label[2] = self.label[4];
    self.label[4] = self.label[3];
    self.label[3] = tmp;
  }
  fn include_of(&self, elem: i32) -> usize {
    self.label.iter().position(|&e| e == elem).unwrap()
  }
  fn include_horizontal(&self, elem: i32) -> bool {
    match self.include_of(elem) {
      1 | 2 | 3 | 4 => true,
      _ => false
    }
  }
  fn include_vertical(&self, elem: i32) -> bool {
    match self.include_of(elem) {
      0 | 1 | 4 | 5 => true,
      _ => false
    }
  }
  fn included(&self, elem: i32) -> bool {
    self.label.iter().any(|&e| e == elem)
  }
  fn is_equal(&self, other: &Dice) -> bool {
    let mut ans = true;
    for i in 0..6 {
      if self.label[i] != other.label[i] {
        ans = false;
        break;
      }
    }
    ans
  }
}

fn main() {
  let cin = stdin();
  let cin = cin.lock();
  let mut sc = Scanner::new(cin);
  sc.new_line();
  let dice1: Vec<i32> = sc.get_as_vec();
  sc.new_line();
  let dice2: Vec<i32> = sc.get_as_vec();
  let mut ans = true;
  for i in dice1.iter() {
    if !dice2.contains(i) {
      ans = false;
    }
  }
  if ans {
    ans = false;
    let dice1 = Dice::new(dice1);
    let mut dice2 = Dice::new(dice2);
    let order = "RRRRNRRRNLLLLNLLLLNLLLNLLL";
    for o in order.chars() {
      match o {
        'N' => dice2.north(),
        'R' => dice2.rot_right(),
        'L' => dice2.rot_left(),
        _   => {}
      }
      if dice1.is_equal(&dice2) {
        ans = true;
        break;
      }
    }
  }
  println!("{}", if ans { "Yes" } else { "No" });
}



Measured memory_bytes: 5032