process.stdin.resume();
process.stdin.setEncoding("utf8");

const reader = require("readline").createInterface({
  input: process.stdin,
  output: process.stdout,
});

const lines = [];

reader.on("line", (line) => {
  lines.push(line);
});

const role = ([top, back, right, left, front, bottom], d) => {
  switch (d) {
    case "N":
      [top, front, bottom, back] = [back, top, front, bottom];
      break;
    case "S":
      [top, front, bottom, back] = [front, bottom, back, top];
      break;
    case "W":
      [top, left, bottom, right] = [right, top, left, bottom];
      break;
    case "E":
      [top, left, bottom, right] = [left, bottom, right, top];
      break;
    case "R":
      [front, left, back, right] = [left, back, right, front];
      break;
  }
  return [top, back, right, left, front, bottom];
};

const cd = (d1, d2) => {
  let ret = true;
  for (let i = 0; i < 6; i++) {
    if (d1[i] !== d2[i]) {
      ret = false;
      break;
    }
  }
  return ret;
};

reader.on("close", () => {
  let dice1 = lines[0].split(" ");
  let dice2 = lines[1].split(" ");
  let match = false;
  for (let i = 0; i < 4; i++) {
    for (let j = 0; j < 4; j++) {
      for (let k = 0; k < 4; k++) {
        match = cd(dice1, dice2);
        if (match) break;
        dice1 = role(dice1, "R");
      }
      match = cd(dice1, dice2);
      if (match) break;
      dice1 = role(dice1, "E");
    }
    match = cd(dice1, dice2);
    if (match) break;
    dice1 = role(dice1, "N");
  }

  console.log(match ? "Yes" : "No");
});

