function Dice( faces ) {
  this.faces = faces;
  this.getFace = function ( id ) {
    return this.faces[id];
  }
  this.roll = function ( cmds ) {
    var t;
    for( var i=0; i<cmds.length; i++ ) {
      if( 'E' == cmds[i] ) {
        t = this.faces[Dice.TOP];
        this.faces[Dice.TOP] = this.faces[Dice.LEFT];
        this.faces[Dice.LEFT] = this.faces[Dice.BOTTOM];
        this.faces[Dice.BOTTOM] = this.faces[Dice.RIGHT];
        this.faces[Dice.RIGHT] = t;
      } else if( 'S' == cmds[i] ) {
        t = this.faces[Dice.TOP];
        this.faces[Dice.TOP] = this.faces[Dice.BACK];
        this.faces[Dice.BACK] = this.faces[Dice.BOTTOM];
        this.faces[Dice.BOTTOM] = this.faces[Dice.FRONT];
        this.faces[Dice.FRONT] = t;
      } else if( 'W' == cmds[i] ) {
        t = this.faces[Dice.TOP];
        this.faces[Dice.TOP] = this.faces[Dice.RIGHT];
        this.faces[Dice.RIGHT] = this.faces[Dice.BOTTOM];
        this.faces[Dice.BOTTOM] = this.faces[Dice.LEFT];
        this.faces[Dice.LEFT] = t;
      } else if( 'N' == cmds[i] ) {
        t = this.faces[Dice.TOP];
        this.faces[Dice.TOP] = this.faces[Dice.FRONT];
        this.faces[Dice.FRONT] = this.faces[Dice.BOTTOM];
        this.faces[Dice.BOTTOM] = this.faces[Dice.BACK];
        this.faces[Dice.BACK] = t;        
      } else if( 'M' == cmds[i] ) {
        t = this.faces[Dice.FRONT];
        this.faces[Dice.FRONT] = this.faces[Dice.RIGHT];
        this.faces[Dice.RIGHT] = this.faces[Dice.BACK];
        this.faces[Dice.BACK] = this.faces[Dice.LEFT];
        this.faces[Dice.LEFT] = t;        
      }
    }
  }
  this.isEqual = function( other ) {
    var i;
    for( i=Dice.TOP; i<=Dice.BOTTOM; i++ ) {
      if( this.getFace( i ) != other.getFace( i ) ) { break; }
    }
    return  (i==6)?true:false;
  }
}
Dice.TOP = 0;
Dice.FRONT = 1;
Dice.RIGHT = 2;
Dice.LEFT = 3;
Dice.BACK = 4;
Dice.BOTTOM = 5;
var input = '';
var readable = process.stdin;
readable.resume();
readable.setEncoding( 'utf-8' );
readable.on( 'data', function( chunk ) {
  input += chunk;
});

readable.on( 'end', function() {
  var data = input.split( '\n' );
  var labels = data[0].split( ' ' ).map( Number );
  var dice = new Dice( labels ); 
  var labels2 = data[1].split( ' ' ).map( Number );
  var dice2 = new Dice( labels2 ); 

  var cmds = "NWWWNMMMM";
  var isequal = false;
  for( var i=0; i<7 && !isequal; i++ ) {
    if( dice2.getFace( Dice.TOP ) == dice.getFace( Dice.TOP ) ) {
      var j;
      for( j=5; j<cmds.length && !isequal; j++ ) {
        if( dice2.getFace( Dice.FRONT ) == dice.getFace( Dice.FRONT ) ) { 
          isequal = dice.isEqual( dice2 );
        }
        dice2.roll( cmds[j] );
      }
    }
    dice2.roll( cmds[i] );
  }
  if( isequal) {
    console.log( "Yes" );
  } else {
    console.log( "No" );
  }
});