using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

//ITP1_11-C

namespace ConsoleApplication26
{
    class Dice
    {
        int[] DArray1,DArray2;


        public Dice(int[] a,int[] b)
        {
            DArray1 = a;
            DArray2 = b;
        }

        //int[] Copy()
        //{
        //    int[] Di = new int[DArray2.Length];
        //    for (int i = 0; i < DArray2.Length; ++i)
        //    {
        //        Di[i] = DArray2[i];
        //    }
        //    return Di;
        //}

        public int[] DiceRoll(int roll)
        {
            
            switch (roll)
            {
                case 0:
                    break;

                case 1:
                    RollNorth();
                    break;

                case 2:
                    RollWest();
                    break;

                case 3:
                    RollEast();
                    break;

                case 4:
                    RollSouth();
                    break;

                case 5:
                    RollNorth();
                    RollNorth();
                    break;
            }
           // int[] DArray2 = Copy();
            return DArray2;
        }

        void RollNorth()
        {
            int temp;
            temp = DArray2[0];
            DArray2[0] = DArray2[1];
            DArray2[1] = DArray2[5];
            DArray2[5] = DArray2[4];
            DArray2[4] = temp;
        }

        void RollEast()
        {
            int temp;
            temp = DArray2[0];
            DArray2[0] = DArray2[3];
            DArray2[3] = DArray2[5];
            DArray2[5] = DArray2[2];
            DArray2[2] = temp;
        }

        void RollSouth()
        {
            int temp;
            temp = DArray2[0];
            DArray2[0] = DArray2[4];
            DArray2[4] = DArray2[5];
            DArray2[5] = DArray2[1];
            DArray2[1] = temp;
        }

        void RollWest()
        {
            int temp;
            temp = DArray2[0];
            DArray2[0] = DArray2[2];
            DArray2[2] = DArray2[5];
            DArray2[5] = DArray2[3];
            DArray2[3] = temp;
        }

        public int[] DiceRoll2()
        {
            while (DArray1[1] != DArray2[1])
            {
                int temp;
                temp = DArray2[2];
                DArray2[2] = DArray2[1];
                DArray2[1] = DArray2[3];
                DArray2[3] = DArray2[4];
                DArray2[4] = temp;
            }

            return DArray2;
        }


        public bool hantei()            //???????????????????????°????????????????????????
        {
            for (int i = 2; i < 6; ++i)
            {
                if (DArray2[i] != DArray1[i])
                {
                    return false;
                }
            }
            return true;
        }
    }

    

    class Program
    {
        static void Main()
        {
            string[] str1 = Console.ReadLine().Split(' ');
            int[] DiceArray1 = Array.ConvertAll(str1, int.Parse);
            string[] str2 = Console.ReadLine().Split(' ');
            int[] DiceArray2 = Array.ConvertAll(str2, int.Parse);

            bool bl = false;

            Dice DClass = new Dice(DiceArray1,DiceArray2);

            for (int i = 0; i < DiceArray2.Length; ++i)
            {
                if (DiceArray2[i] == DiceArray1[0])
                {
                    DClass.DiceRoll(i);
                    DClass.DiceRoll2();
                    bl = DClass.hantei();

                    if (bl)
                    {
                        Console.WriteLine("Yes");
                        break;
                    }
                   
                }
            }
            if (!bl)
            {
                  Console.WriteLine("No");
            }
           
        }
    }
}

Measured memory_bytes: 19656