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

namespace ConsoleApp2
{
    class Program
    {

        static void Main(string[] args)
        {
            List<int> intlist = new List<int>();
             
            //??????????´??????°
            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);

            intlist.Add(int.Parse(dice[0]));
            intlist.Add(int.Parse(dice[1]));
            intlist.Add(int.Parse(dice[2]));
            intlist.Add(int.Parse(dice[3]));
            intlist.Add(int.Parse(dice[4]));
            intlist.Add(int.Parse(dice[5]));

            //int one = int.Parse(dice[0]);
            //int two = int.Parse(dice[1]);
            //int therr = int.Parse(dice[2]);
            //int four = int.Parse(dice[3]);
            //int five = int.Parse(dice[4]);
            //int six = int.Parse(dice[5]);





            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.Under == onedice.Under && (onedice.S == secdice.W || onedice.S == secdice.E) && (onedice.N == secdice.W || onedice.N == secdice.E)) result = "Yes";

                if (onedice.SameInt(intlist)) 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("S");
                    MoveDice("S");
                    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 bool SameInt(List<int> list)
        {
            List<int> upcount = list.FindAll(x => x == this.Up);
            List<int> undercount = list.FindAll(x => x == this.Under);
            List<int> scount = list.FindAll(x => x == this.S);
            List<int> ecount = list.FindAll(x => x == this.E);
            List<int> wcount = list.FindAll(x => x == this.W);
            List<int> ncount = list.FindAll(x => x == this.N);

            if (upcount.Count >= 5 || undercount.Count >= 5 || scount.Count >= 5 || ecount.Count >= 5 || wcount.Count >= 5 || ncount.Count >= 5) return true;

            return false;

        }
    }


}

Measured memory_bytes: 9076