using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

class program{
    public static void Main(){
        var nums1 = Console.ReadLine().Split(' ').Select(_ => int.Parse(_)).ToList();
        var dice1 = new Dice(nums1);
        var nums2 = Console.ReadLine().Split(' ').Select(_ => int.Parse(_)).ToList();
        var dice2 = new Dice(nums2);

        if(Dice.SameDice(dice1,dice2)){
            Console.WriteLine("Yes");
        }else{
            Console.WriteLine("No");
        }
    }
}

class Dice{
    public List<Face> faces = new List<Face>(6);

    public Dice(List<int> nums){
        faces.Add(new Face(nums[0],'T'));
        faces.Add(new Face(nums[1],'S'));
        faces.Add(new Face(nums[2],'E'));
        faces.Add(new Face(nums[3],'W'));
        faces.Add(new Face(nums[4],'N'));
        faces.Add(new Face(nums[5],'B'));
    }

    public void Rotate(char dir){
        if(dir == 'N'){
            var tmpnum = getFace('T').num;
            getFace('T').num = getFace('S').num;
            getFace('S').num = getFace('B').num;
            getFace('B').num = getFace('N').num;
            getFace('N').num = tmpnum;
        }
        if(dir == 'W'){
            var tmpnum = getFace('T').num;
            getFace('T').num = getFace('E').num;
            getFace('E').num = getFace('B').num;
            getFace('B').num = getFace('W').num;
            getFace('W').num = tmpnum;
        }
        if(dir == 'S'){
            var tmpnum = getFace('T').num;
            getFace('T').num = getFace('N').num;
            getFace('N').num = getFace('B').num;
            getFace('B').num = getFace('S').num;
            getFace('S').num = tmpnum;
        }
        if(dir == 'E'){
            var tmpnum = getFace('T').num;
            getFace('T').num = getFace('W').num;
            getFace('W').num = getFace('B').num;
            getFace('B').num = getFace('E').num;
            getFace('E').num = tmpnum;
        }
    }

    public int getRightNum(int top, int south){
        var s = faces.First(_ => _.num == south);

        if(s.dir == 'N'){
            Rotate('N');
            Rotate('N');
        }
        if(s.dir == 'T'){
            Rotate('S');
        }
        if(s.dir == 'E'){
            Rotate('W');
            Rotate('S');
        }
        if(s.dir == 'W'){
            Rotate('E');
            Rotate('S');
        }
        if(s.dir == 'B'){
            Rotate('N');
        }

        var t = faces.First(_ => _.num == top);

        if(t.dir == 'W'){
            Rotate('E');
        }
        if(t.dir == 'B'){
            Rotate('E');
            Rotate('E');
        }
        if(t.dir == 'E'){
            Rotate('W');
        }

        return getFace('E').num;
    }

    public Face getFace(char d){
        return faces.First(_ => _.dir == d);
    }

    public static bool SameDice(Dice dice1, Dice dice2){
        //sをあわせる
        var s = dice2.faces.First(_ => _.num == dice1.getFace('S').num);

        if(s.dir == 'N'){
            dice2.Rotate('N');
            dice2.Rotate('N');
        }
        if(s.dir == 'T'){
            dice2.Rotate('S');
        }
        if(s.dir == 'E'){
            dice2.Rotate('W');
            dice2.Rotate('S');
        }
        if(s.dir == 'W'){
            dice2.Rotate('E');
            dice2.Rotate('S');
        }
        if(s.dir == 'B'){
            dice2.Rotate('N');
        }

        //tをあわせる
        var t = dice2.faces.First(_ => _.num == dice1.getFace('T').num);
        if(t.dir == 'N') return false;

        if(t.dir == 'W'){
            dice2.Rotate('E');
        }
        if(t.dir == 'B'){
            dice2.Rotate('E');
            dice2.Rotate('E');
        }
        if(t.dir == 'E'){
            dice2.Rotate('W');
        }

        if(Dice.compFacenum(dice1,dice2,'E') && Dice.compFacenum(dice1,dice2,'W') && Dice.compFacenum(dice1,dice2,'N') && Dice.compFacenum(dice1,dice2,'B')){
            return true;
        }else{
            return false;
        }
    }

    public static bool compFacenum(Dice dice1, Dice dice2, char dir){
        var f1 = dice1.getFace(dir);
        var f2 = dice2.getFace(dir);
        return f1.num == f2.num;
    }
}

class Face{
    public int num;
    public char dir;

    public Face(int n, char d){
        num = n;
        dir = d;
    }
}



Measured memory_bytes: 18412