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

namespace _20170409_AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] iArr1 = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            int[] iArr2 = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();

            Dice dice1 = new Dice(iArr1);
            Dice dice2 = new Dice(iArr2);
            
            dice2.SetTopFront(dice1.Top, dice1.Front);

            if (Dice.IsSame(dice1,dice2))
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }

            Console.ReadLine();
        }
    }

    class Dice
    {
        public enum Dir
        {
            N,
            S,
            W,
            E,
            L,
            R
        }


        int[] iArr = new int[6];
        int[,] tenkai;
        public Dice(int[] arr)
        {
            int len = Math.Min(iArr.Length, arr.Length);
            for (int i = 0; i < len; i++)
            {
                iArr[i] = arr[i];
            }

            tenkai = CreateTenkai();
        }

        public Dice(Dice _dice)
        {
            iArr[0] = _dice.Top;
            iArr[1] = _dice.Front;
            iArr[2] = _dice.Right;
            iArr[3] = _dice.Left;
            iArr[4] = _dice.Back;
            iArr[5] = _dice.Bottom;

            tenkai = CreateTenkai();
        }

        public int Top { get { return iArr[tenkai[1, 1]]; } }
        public int Bottom { get { return iArr[tenkai[1, 3]]; } }
        public int Front { get { return iArr[tenkai[2, 1]]; } }
        public int Back { get { return iArr[tenkai[0, 1]]; } }
        public int Left { get { return iArr[tenkai[1, 0]]; } }
        public int Right { get { return iArr[tenkai[1, 2]]; } }

        public static Boolean IsSame(Dice _dice1, Dice _dice2)
        {
            Dice td1 = new Dice(_dice1);
            Dice td2 = new Dice(_dice2);

            for (int v = 0; v < 6; v++)
            {
                for (int h = 0; h < 4; h++)
                {
                    if (td1.Top == td2.Top &&
                        td1.Bottom == td2.Bottom &&
                        td1.Front == td2.Front &&
                        td1.Back == td2.Back &&
                        td1.Left == td2.Left &&
                        td1.Right == td2.Right)
                    {
                        return true;
                    }
                    else
                    {
                        td2.Move(Dir.L);
                    }
                }

                if (v % 2 == 0)
                {
                    td2.Move(Dir.N);
                }
                else
                {
                    td2.Move(Dir.W);
                }
            }

            return false;
        }

        public void SetTopFront(int _top, int _front)
        {
            for (int i = 0; i < 3; i++)
            {
                if (_top == Top)
                {
                    break;
                }
                Move(Dir.N);
                if (_top == Top)
                {
                    break;
                }
                Move(Dir.W);
            }

            for (int i = 0; i < 3; i++)
            {
                if (_front == Front)
                {
                    break;
                }
                Move(Dir.L);
            }
        }

        public void Move(char c)
        {
            switch (c)
            {
                case 'N': Move(Dir.N); break;
                case 'S': Move(Dir.S); break;
                case 'W': Move(Dir.W); break;
                case 'E': Move(Dir.E); break;
                case 'L': Move(Dir.L); break;
                case 'R': Move(Dir.R); break;
            }
        }

        public void Move(Dir dir)
        {
            switch(dir)
            {
                case Dir.N:
                    {
                        int tmp = tenkai[1, 1];
                        tenkai[1, 1] = tenkai[2, 1];
                        tenkai[2, 1] = tenkai[1, 3];
                        tenkai[1, 3] = tenkai[0, 1];
                        tenkai[0, 1] = tmp;
                    }
                    break;
                case Dir.S:
                    {
                        int tmp = tenkai[1, 1];
                        tenkai[1, 1] = tenkai[0, 1];
                        tenkai[0, 1] = tenkai[1, 3];
                        tenkai[1, 3] = tenkai[2, 1];
                        tenkai[2, 1] = tmp;
                    }
                    break;
                case Dir.W:
                    {
                        int tmp = tenkai[1, 1];
                        tenkai[1, 1] = tenkai[1, 2];
                        tenkai[1, 2] = tenkai[1, 3];
                        tenkai[1, 3] = tenkai[1, 0];
                        tenkai[1, 0] = tmp;
                    }
                    break;
                case Dir.E:
                    {
                        int tmp = tenkai[1, 1];
                        tenkai[1, 1] = tenkai[1, 0];
                        tenkai[1, 0] = tenkai[1, 3];
                        tenkai[1, 3] = tenkai[1, 2];
                        tenkai[1, 2] = tmp;
                    }
                    break;
                case Dir.L:
                    {
                        int tmp = tenkai[2, 1];
                        tenkai[2, 1] = tenkai[1, 2];
                        tenkai[1, 2] = tenkai[0, 1];
                        tenkai[0, 1] = tenkai[1, 0];
                        tenkai[1, 0] = tmp;
                    }
                    break;
                case Dir.R:
                    {
                        int tmp = tenkai[2, 1];
                        tenkai[2, 1] = tenkai[1, 0];
                        tenkai[1, 0] = tenkai[0, 1];
                        tenkai[0, 1] = tenkai[1, 2];
                        tenkai[1, 0] = tmp;
                    }
                    break;
            }
        }

        private int[,] CreateTenkai()
        {
            int[,] arr = new int[,]{
                { -1,  4, -1, -1 },
                {  3,  0,  2,  5 },
                { -1,  1, -1, -1 },
            };

            return arr;
        }
    }
}

Measured memory_bytes: 9364