using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
//using System.Threading.Tasks;

namespace Dice_II
{
    class Program
    {
        static void Main(string[] args)
        {
            var input_a = Console.ReadLine().Split(' ');
            var input_b = Console.ReadLine().Split(' ');
            Dice a = new Dice(input_a);
            Dice b = new Dice(input_b);
            Console.WriteLine(Is_Dice_Equal(ref a, ref b) ? "Yes" : "No");
        }

        static bool Is_Dice_Equal(ref Dice a, ref Dice b)
        {
            if ((a[0] == b[2] || a[0] == b[3]) && (a[5] == b[2] || a[5] == b[3]))
            {
                var work = b[1];
                b[1] = b[2];
                b[2] = b[4];
                b[4] = b[3];
                b[3] = work;
            }
            for (int i = 0; i < 3; ++i)
            {
                if ((a[0] == b[0]) && (a[5] == b[5])) break;
                b.Rotation('N');
            }// End_for
            for (int i = 0; i < 3; ++i)
            {
                if ((a[1] == b[1]) && (a[4] == b[4])) break;
                var work = b[1];
                b[1] = b[2];
                b[2] = b[4];
                b[4] = b[3];
                b[3] = work;
            }// End_for
            return Check_Dice(a, b);
        }

        static bool Check_Dice(Dice a, Dice b)
        {
            for (int i = 0; i < 6; ++i)
            {
                if (a[i] != b[i]) return false;
            }
            return true;
        }
    }


    class Dice
    {
        public int[] surface;

        public Dice()
        {
            Console.WriteLine("???????????\????????????");
            Environment.Exit(-1);
        }
        public Dice(String[] str)
        {
            surface = new int[6];
            for (int i = 0; i < 6; ++i)
            {
                this.surface[i] = int.Parse(str[i]);
            }
        }// End_Constructor
        public Dice(int[] input)
        {
            for (int i = 0; i < 6; ++i)
            {
                this.surface[i] = input[i];
            }
        }// End_Constructor

        //(??????)????????§???
        public int[] Get_Surface()
        {
            return this.surface;
        }
        public int Get_Surface(int n)
        {
            return this.surface[n];
        }

        //???????????????(private?????????????????????????????§??????public????\????????????????)
        public int this[int n]
        {
            get
            {
                return this.surface[n];
            }
            set
            {
                this.surface[n] = value;
            }
        }

        public void Rotation(char c)
        {
            switch (c)
            {
                case 'E':
                    this.Rotation_E();
                    break;
                case 'N':
                    this.Rotation_N();
                    break;
                case 'S':
                    this.Rotation_S();
                    break;
                case 'W':
                    this.Rotation_W();
                    break;
                default:
                    Console.WriteLine("??\?????¨???????");
                    Environment.Exit(-1);
                    break;
            }
        }// End_Rotation

        private void Rotation_E()
        {
            this.Rotation_Run(0, 3, 5, 2);
        }

        private void Rotation_N()
        {
            this.Rotation_Run(0, 1, 5, 4);
        }

        private void Rotation_S()
        {
            this.Rotation_Run(0, 4, 5, 1);
        }
        private void Rotation_W()
        {
            this.Rotation_Run(0, 2, 5, 3);
        }

        static void Swap(ref int a, ref int b)
        {
            var t = a;
            a = b;
            b = t;
        }

        void Rotation_Run(int a, int b, int c, int d)
        {
            var work = this.surface[a];
            this.surface[a] = this.surface[b];
            this.surface[b] = this.surface[c];
            this.surface[c] = this.surface[d];
            this.surface[d] = work;
        }// End_Rotation_Run

        public int Right_Surface(int a, int b)
        {
            if (a == this.surface[0])
            {
                if (b == this.surface[1]) return this.surface[2];
                if (b == this.surface[2]) return this.surface[4];
                if (b == this.surface[3]) return this.surface[1];
                if (b == this.surface[4]) return this.surface[3];
            }   
            else if (a == this.surface[1])
            {
                if (b == this.surface[0]) return this.surface[3];
                if (b == this.surface[2]) return this.surface[0];
                if (b == this.surface[3]) return this.surface[5];
                if (b == this.surface[5]) return this.surface[2];
            }
            else if (a == this.surface[2])
            {
                if (b == this.surface[0]) return this.surface[1];
                if (b == this.surface[1]) return this.surface[5];
                if (b == this.surface[5]) return this.surface[4];
                if (b == this.surface[4]) return this.surface[0];
            }
            else if (a == this.surface[3])
            {
                if (b == this.surface[0]) return this.surface[4];
                if (b == this.surface[1]) return this.surface[0];
                if (b == this.surface[4]) return this.surface[5];
                if (b == this.surface[5]) return this.surface[1];
            }
            else if (a == this.surface[4])
            {
                if (b == this.surface[0]) return this.surface[2];
                if (b == this.surface[2]) return this.surface[5];
                if (b == this.surface[3]) return this.surface[0];
                if (b == this.surface[5]) return this.surface[3];
            }
            else if (a == this.surface[5])
            {
                if (b == this.surface[1]) return this.surface[3];
                if (b == this.surface[2]) return this.surface[1];
                if (b == this.surface[3]) return this.surface[4];
                if (b == this.surface[4]) return this.surface[2];
            }
            else
            {
                Console.WriteLine("???????????????");
                return -1;
            }
            return -1;
        }// End_Right_Surface
    }// End_CLass
}


Measured memory_bytes: 8916