using System;

namespace ITP1_11_C
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str1 = Console.ReadLine().Split(' ');
            Dice dice1 = new Dice(int.Parse(str1[0]), int.Parse(str1[1]), int.Parse(str1[2]), int.Parse(str1[3]), int.Parse(str1[4]), int.Parse(str1[5]));

            string[] str2 = Console.ReadLine().Split(' ');
            Dice dice2 = new Dice(int.Parse(str2[0]), int.Parse(str2[1]), int.Parse(str2[2]), int.Parse(str2[3]), int.Parse(str2[4]), int.Parse(str2[5]));

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

        }

        static bool checkSame(Dice dice1,Dice dice2)
        {
            return (true
                && dice1.TopPip == dice2.TopPip
                && dice1.NorthPip == dice2.NorthPip
                && dice1.SouthPip == dice2.SouthPip
                && dice1.WestPip == dice2.WestPip
                && dice1.EastPip == dice2.EastPip
                && dice1.BottomPip == dice2.BottomPip
                );
        }

        static bool revolveCheckSame(Dice dice1,Dice dice2)
        {
            for (int i = 0; i < 4; ++i) 
            {
                if (checkSame(dice1, dice2)) { return true; }
                dice2.RevolveLeft();
            }
            return false;
        }

        static bool allCheckSame(Dice dice1,Dice dice2)
        {
            if (revolveCheckSame(dice1, dice2)) { return true; }

            dice2.MoveEast();
            if (revolveCheckSame(dice1, dice2)) { return true; }
            dice2.MoveWest();

            dice2.MoveNorth();
            if (revolveCheckSame(dice1, dice2)) { return true; }
            dice2.MoveSouth();

            dice2.MoveSouth();
            if (revolveCheckSame(dice1, dice2)) { return true; }
            dice2.MoveNorth();

            dice2.MoveWest();
            if (revolveCheckSame(dice1, dice2)) { return true; }

            dice2.MoveWest();
            if (revolveCheckSame(dice1, dice2)) { return true; }

            return false;
        }
    }

    class Dice
    {
        public int TopPip { get; private set; }
        public int SouthPip { get; private set; }
        public int EastPip { get; private set; }
        public int WestPip { get; private set; }
        public int NorthPip { get; private set; }
        public int BottomPip { get; private set; }

        public Dice(int topPip, int southPip, int eastPip, int westPip, int northPip, int bottomPip)
        {
            this.TopPip = topPip;
            this.SouthPip = southPip;
            this.EastPip = eastPip;
            this.WestPip = westPip;
            this.NorthPip = northPip;
            this.BottomPip = bottomPip;
        }

        public Dice(Dice dice)
        {
            this.TopPip = dice.TopPip;
            this.SouthPip = dice.SouthPip;
            this.EastPip = dice.EastPip;
            this.WestPip = dice.WestPip;
            this.NorthPip = dice.NorthPip;
            this.BottomPip = dice.BottomPip;
        }

        public void MoveNorth()
        {
            int temp = this.NorthPip;
            this.NorthPip = this.TopPip;
            this.TopPip = this.SouthPip;
            this.SouthPip = this.BottomPip;
            this.BottomPip = temp;
        }

        public void MoveSouth()
        {
            int temp = this.SouthPip;
            this.SouthPip = this.TopPip;
            this.TopPip = this.NorthPip;
            this.NorthPip = this.BottomPip;
            this.BottomPip = temp;
        }

        public void MoveWest()
        {
            int temp = this.WestPip;
            this.WestPip = this.TopPip;
            this.TopPip = this.EastPip;
            this.EastPip = this.BottomPip;
            this.BottomPip = temp;
        }

        public void MoveEast()
        {
            int temp = this.EastPip;
            this.EastPip = this.TopPip;
            this.TopPip = this.WestPip;
            this.WestPip = this.BottomPip;
            this.BottomPip = temp;
        }

        public void RevolveLeft()
        {
            int temp = this.SouthPip;
            this.SouthPip = this.EastPip;
            this.EastPip = this.NorthPip;
            this.NorthPip = this.WestPip;
            this.WestPip = temp;
        }
    }
}

Measured memory_bytes: 17532