//config = {stdin: 'tmp', newline: '\r\n'}; // win
config = {stdin: '/dev/stdin', newline: '\n'}; // linux

line = require('fs').readFileSync(config.stdin, 'ascii')
       .split(config.newline, 2);

a = line[0].split(' ');
b = line[1].split(' ');

dice_pos = {
  1: [0, 0, 0.5], 2: [0, -0.5, 0], 3: [0.5, 0, 0],
  4: [-0.5, 0, 0], 5: [0, 0.5, 0], 6: [0, 0, -0.5] };

function find(i) {
  return b.indexOf(a[i - 1]);
}

function sub(x, y) {
  return [x[0] - y[0], x[1] - y[1], x[2] - y[2]];
}

function get_vector_by_index(i, j) {
  var pi = find(i), pj = find(j);
  if (pi === -1 || pj === -1) return null;
  return sub(dice_pos[pi + 1], dice_pos[pj + 1]);
}

v16 = get_vector_by_index(6, 1);
v25 = get_vector_by_index(5, 2);
v34 = get_vector_by_index(4, 3);

if (v16 === null || v25 === null || v34 === null) {
  console.log("No");
} else {
  outer = [ v16[1] * v25[2] - v16[2] * v25[1],
            v16[2] * v25[0] - v16[0] * v25[2],
            v16[0] * v25[1] - v16[1] * v25[0] ];
  if (outer[0] === -v34[0] && outer[1] === -v34[1] && outer[2] == -v34[2])
    console.log("Yes");
  else
    console.log("No");
}