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

namespace ConsoleApplication27
{
    class Dice
    {
        int[] DArray;


        public Dice(int[] a)
        {
            DArray = a;
        }

        public void 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;
            }
        }

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

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

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

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

        public bool DiceRoll2(int a)
        {
            int count = 1;
            while (a != DArray[1])
            {
                if (count == 4)
                {
                    return false;
                }
                int temp;
                temp = DArray[2];
                DArray[2] = DArray[1];
                DArray[1] = DArray[3];
                DArray[3] = DArray[4];
                DArray[4] = temp;
                ++count;
            }

            return true;
        }


        public bool hantei1(int[] DA)           
        {
            for (int i = 2; i < DArray.Length; ++i)
            {
                if (DArray[i] != DA[i])
                {
                    return false;
                }
            }
            return true;
        }

         public bool hantei2(Dice D2)
         {
             for (int i = 0; i < D2.DArray.Length; ++i)
             {
                 if (D2.DArray[0] == DArray[i])
                 {
                     DiceRoll(i);
                     DiceRoll2(D2.DArray[1]);


                     bool bl = hantei1(D2.DArray);

                     if (bl)
                     {
                         return true;
                     }
                 }
             }
             return false;
         }
   
    }
   


    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);

            Dice dice1 = new Dice(DiceArray1);
            Dice dice2 = new Dice(DiceArray2);

            bool b = dice1.hantei2(dice2);

            if (b)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }

        }
    }
}

Measured memory_bytes: 19652