Problem:
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});

Dice III

Write a program which reads the two dices constructed in the same way as Dice I, and determines whether these two dices are identical. You can roll a dice in the same way as Dice I, and if all integers observed from the six directions are the same as that of another dice, these dices can be considered as identical.

Input

In the first line, six integers assigned to faces of a dice are given in ascending order of their corresponding labels.

In the second line, six integers assigned to faces of another dice are given in ascending order of their corresponding labels.

Output

Print "Yes" if two dices are identical, otherwise "No" in a line.

Constraints

$0 \leq $ the integer assigned to a face $ \leq 100$

Sample Input 1

1 2 3 4 5 6
6 2 4 3 5 1

Sample Output 1

Yes

Sample Input 2

1 2 3 4 5 6
6 5 4 3 2 1

Sample Output 2

No

Solution in C# (judge verdict: Wrong Answer)

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

namespace ConsoleApp2
{
    class Program
    {

        static void Main(string[] args)
        {

            //??????????´??????°
            string result = "No";

            //???????????????????????????
            string[] dice = Console.ReadLine().Split(' ');

            var onedice = new Dice(int.Parse(dice[0]), int.Parse(dice[1]), int.Parse(dice[2]), int.Parse(dice[3]), int.Parse(dice[4]), int.Parse(dice[5]));

            //2????????????????????????????????????
            string[] seconddice = Console.ReadLine().Split(' ');

            var secdice = new Dice(int.Parse(seconddice[0]), int.Parse(seconddice[1]), int.Parse(seconddice[2]), int.Parse(seconddice[3]), int.Parse(seconddice[4]), int.Parse(seconddice[5]));

            var upflow = secdice.GetFlow(onedice.Up);
            //
            if(upflow != string.Empty)
            {
                secdice.MoveUp(upflow);

                if ((secdice.Under == onedice.Under) && ((secdice.S == onedice.S && secdice.W == onedice.W && secdice.E == onedice.E) || (secdice.S == onedice.N && secdice.W == onedice.E))) result = "Yes";
                //if (((secdice.S == onedice.S && secdice.W == onedice.W && secdice.E == onedice.E) || (secdice.S == onedice.N && secdice.W == onedice.E))) result = "Yes";
                if (secdice.Under != onedice.Under) result = "Yes";
            }

            Console.WriteLine(result);

        }

    }

    class Dice
    {
        //??????????????°
        public int N = -1;
        public int Under = -1;
        public int E = -1;
        public int W = -1;
        public int Up = -1;
        public int S = -1;

        Dictionary<string, int> diceEye;


        #region ?????????????????????
        //????????????????????¨????????????????????????
        public Dice(int up, int s, int e, int w, int n, int under)
        {
            CreateDictionary(up, s, e, w, n, under);

            Up = up;
            S = s;
            E = e;
            W = w;
            N = n;
            Under = under;
        }
        #endregion



        public void MoveDice(string direction)
        {
            //????????¨????????°???????§??????????????????????
            this.Under = this.diceEye[direction];


            //????????¨???Under?????°???????????°???????§??????????
            //??¢?????????????§??????°??????????????????(S ??? N, W ??? E)
            switch (direction)
            {
                case "S":
                    this.N = this.diceEye["Under"];
                    this.S = this.diceEye["Up"];
                    this.Up = this.diceEye["N"];
                    break;


                case "E":
                    this.W = this.diceEye["Under"];
                    this.E = this.diceEye["Up"];
                    this.Up = this.diceEye["W"];
                    break;


                case "N":
                    this.S = this.diceEye["Under"];
                    this.N = this.diceEye["Up"];
                    this.Up = this.diceEye["S"];
                    break;


                case "W":
                    this.E = this.diceEye["Under"];
                    this.W = this.diceEye["Up"];
                    this.Up = this.diceEye["E"];
                    break;
            }

            //?????£????????§??????????????????
            CreateDictionary(this.Up, this.S, this.E, this.W, this.N, this.Under);
        }


        //?????£????????§?????????????????????
        public void CreateDictionary(int up, int s, int e, int w, int n, int under)
        {
            this.diceEye = new Dictionary<string, int>();

            this.diceEye.Add("Up", up);
            this.diceEye.Add("S", s);
            this.diceEye.Add("E", e);
            this.diceEye.Add("W", w);
            this.diceEye.Add("N", n);
            this.diceEye.Add("Under", under);

        }


        //???????????°???????????????????????????????????????
        public string GetFlow(int eye)
        {
            List<string> keylist = new List<string>(this.diceEye.Keys);

            string result = string.Empty;

            foreach (var key in keylist)
            {
                if (eye == diceEye[key])
                {
                    result = key;
                    break;
                }
            }

            return result;
        }

        //????????????????????¢????§?????????????????????????
        public void MoveUp(string upflow)
        {
            switch (upflow)
            {
                case "Under":
                    MoveDice("N");
                    MoveDice("N");
                    break;

                case "S":
                    MoveDice("N");
                    break;

                case "E":
                    MoveDice("W");
                    break;

                case "W":
                    MoveDice("E");
                    break;

                case "N":
                    MoveDice("S");
                    break;

                case "Up":
                    break;
            }
        }

        //?????°????????¢?????°?????????????¶?????????°????????????????????????
        public int OppositeSum(string flow)
        {
            int result = 0;
            switch (flow)
            {
                case "S":
                case "N":
                    result = this.diceEye["S"] + this.diceEye["N"];
                    break;

                case "W":
                case "E":
                    result = this.diceEye["W"] + this.diceEye["E"];
                    break;

                case "Up":
                case "Under":
                    result = this.diceEye["Up"] + this.diceEye["Under"];
                    break;
            }

            return result;
        }

        public int SameInt(List<int> list)
        {
            List<string> keylist = new List<string>(this.diceEye.Keys);

            List<int> countlist = new List<int>();


            foreach(var set in keylist)
            {
                foreach(var intlist in list)
                {
                    if(intlist == this.diceEye[set])
                    {
                        countlist.Add(intlist);
                    }
                }

            }

            return countlist.Count;
        }
    }


}