using System;

namespace Aizu
{
    class Program
    {
        static void Main(string[] args)
        {
            // Dice1を作成
            var diceValue1 = Console.ReadLine();
            var dice1 = new Dice(diceValue1);

            // Dice2を作成
            var diceValue2 = Console.ReadLine();
            var dice2 = new Dice(diceValue2);
            
            // 比較
            var ret = dice2.Judge(dice1);

            // 結果
            Console.WriteLine(ret);
        }
    }

    class Dice
    {
        public int Top { get; private set; }
        public int Bottom { get; private set; }
        public int Right { get; private set; }
        public int Left { get; private set; }
        public int Front { get; private set; }
        public int Back { get; private set; }

        public Dice(string value)
        {
            var temp = value.Split(' ');
            this.Top = int.Parse(temp[0]);
            this.Front = int.Parse(temp[1]);
            this.Right = int.Parse(temp[2]);
            this.Left = int.Parse(temp[3]);
            this.Back = int.Parse(temp[4]);
            this.Bottom = int.Parse(temp[5]);
        }
 
        /// <summary>
        /// 受け取ったダイスのTopとBottomに一致する箇所を調べその時の側面が一致するかチェックする
        /// </summary>
        /// <param name="dice">比較対象のダイス</param>
        /// <returns>True:一致, False:不一致</returns>
        public string Judge(Dice dice)
        {
            string judge = "No";
            int[] diceSide = new int[] { dice.Front, dice.Right, dice.Back, dice.Left };

            // Top, Bottom
            if (dice.Top == this.Top && dice.Bottom == this.Bottom)
            {
                int[] thisDiceSide = new int[] { this.Front, this.Right, this.Back, this.Left };
                judge = JudgeSide(diceSide, thisDiceSide);
            }

            // Bottom, Top
            if (dice.Top == this.Bottom && dice.Bottom == this.Top)
            {
                int[] thisDiceSide = new int[] { this.Front, this.Left, this.Back, this.Right };
                judge = JudgeSide(diceSide, thisDiceSide);
            }

            // Right, Left
            if (dice.Top == this.Right && dice.Bottom == this.Left)
            {
                int[] thisDiceSide = new int[] { this.Front, this.Bottom, this.Back, this.Top };
                judge = JudgeSide(diceSide, thisDiceSide);
            }

            // Left, Right
            if (dice.Top == this.Left && dice.Bottom == this.Right)
            {
                int[] thisDiceSide = new int[] { this.Front, this.Top, this.Back, this.Bottom };
                judge = JudgeSide(diceSide, thisDiceSide);
            }

            // Front, Back
            if (dice.Top == this.Front && dice.Bottom == this.Back)
            {
                int[] thisDiceSide = new int[] { this.Bottom, this.Right, this.Top, this.Left };
                judge = JudgeSide(diceSide, thisDiceSide);
            }

            // Back, Front
            if (dice.Top == this.Back && dice.Bottom == this.Front)
            {
                int[] thisDiceSide = new int[] { this.Bottom, this.Left, this.Top, this.Right };
                judge = JudgeSide(diceSide, thisDiceSide);
            }

            return judge;
        }

        public string JudgeSide(int[] diceSide, int[] thisDiceSide)
        {
            for(int ds = 0; ds < 4; ds++)
            {
                int start = 0;
                for(int tds = start; tds < 4; tds++)
                {
                    if(diceSide[ds % 4] == thisDiceSide[tds % 4] 
                        && diceSide[(ds + 1) % 4] == thisDiceSide[(tds + 1) % 4]
                        && diceSide[(ds + 2) % 4] == thisDiceSide[(tds + 2) % 4]
                        && diceSide[(ds + 3) % 4] == thisDiceSide[(tds + 3) % 4])
                    {
                        return "Yes";
                    }

                    start++;
                }
            }
            
            return "No";
        }
    }
}



Measured memory_bytes: 9028