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

namespace Saikoro
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] a1 = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int[] a2 = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            var s1 = new Saikoro(a1);
            var s2 = new Saikoro(a2);
            if (s1.Equal(s2))
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
    class Saikoro
    {
        public int[] men { get; set; }

        public Saikoro(int[] men)
        {
            this.men = men;
        }
        public void  showTop()
        {
            Console.WriteLine(men[0]);
        }
        public bool Equal(Saikoro s)
        {
            //int frontId = SearchId(s.men[0]);
            //int topId;
            //if (s.men[0] == s.men[1])
            //{
            //    topId = SearchId(s.men[1], frontId);
            //}
            //else
            //{
            //    topId = SearchId(s.men[1]);
            //}
            
            //if (frontId == -1||topId==-1)
            //{
            //    return false;
            //}
            //int rightId = ShowRightSide(men[frontId], men[topId]);
            //if (rightId!=-1&&men[rightId] == s.men[3]&&men[5 - frontId] == s.men[5] && men[5 - topId] == s.men[4] && men[5-rightId] == s.men[2])
            //{
            //    return true;
            //}
            //return false;
            for(int frontId = 0; frontId < 6; frontId++)
            {
                if (!(men[frontId] == s.men[0] && men[5 - frontId] == s.men[5]))
                {
                    continue;
                }
                for(int topId = 0; topId < 6; topId++)
                {
                    int rightId = ReturnRightSide(frontId, topId);
                    if (rightId == -1)
                    {
                        continue;
                    }
                    if (men[topId]==s.men[1]&&men[5-topId]==s.men[4]&&men[rightId] == s.men[3] && men[5-rightId] == s.men[2])
                    {
                        return true;
                    }
                    
                }
                
            }
            return false;
        }

        public int ShowRightSide(int front,int top)
        {
            int frontId = SearchId(front);
            int topId = SearchId(top);
            return ReturnRightSide(frontId, topId);
            
        }
        private int ReturnRightSide(int frontId,int topId)
        {
            int[,] answer =
                        {
                {-1,3,1,4,2,-1 },
                { 2,-1,5,0,-1,3},
                {4,0,-1,-1,5,1 },
                {1,5,-1,-1,0,4 },
                { 3,-1,0,5,-1,2},
                { -1,2,4,1,3,-1},
            };
            return answer[frontId, topId];
        }
        private int SearchId(int num)
        {
            return SearchId(num, 0);
        }
        private int SearchId(int num,int startId)
        {
            for (int i = startId; i < men.Length; i++)
            {
                if (num == men[i])
                {
                    return i;
                }
            }
            return -1;
        }

        public void Move(char c)
        {
            switch (c)
            {
                case 'N':
                    N();
                    break;
                case 'S':
                    S();
                    break;
                case 'E':
                    E();
                    break;
                case 'W':
                    W();
                    break;
                default:
                    break;
            }
        }
        private void N()
        {
            var temp = (int[])men.Clone();
            men[0] = temp[1];
            men[1] = temp[5];
            men[5] = temp[4];
            men[4] = temp[0];
        }
        private void W()
        {
            var temp =(int[]) men.Clone();
            men[0] = temp[2];
            men[2] = temp[5];
            men[5] = temp[3];
            men[3] = temp[0];
        }
        private void E()
        {
            var temp = (int[])men.Clone();
            men[2] = temp[0];
            men[5] = temp[2];
            men[3] = temp[5];
            men[0] = temp[3];
        }
        private void S()
        {
            var temp = (int[])men.Clone();
            men[0] = temp[4];
            men[4] = temp[5];
            men[5] = temp[1];
            men[1] = temp[0];

        }
    }
}



Measured memory_bytes: 20464