using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace _001_FindingMissingCards
{
    class Dice
    {
        private int[] num = new int[7];
        private int[] reverse = new int[100];

        public Dice(int[]given)
        {
            num[1] = given[0];
            num[2] = given[1];
            num[3] = given[2];
            num[4] = given[3];
            num[5] = given[4];
            num[6] = given[5];

            reverse[given[0]] = 1;
            reverse[given[1]] = 2;
            reverse[given[2]] = 3;
            reverse[given[3]] = 4;
            reverse[given[4]] = 5;
            reverse[given[5]] = 6;
        }

        private int rightNum(int numa, int numb)
        {
            int x = 0;

            if ((numa == 2 && numb == 3) ||
                (numa == 3 && numb == 5) ||
                (numa == 4 && numb == 2) ||
                (numa == 5 && numb == 4))
            {
                x = 1;
            }
            else if (
                (numa == 1 && numb == 4) ||
                (numa == 3 && numb == 1) ||
                (numa == 4 && numb == 6) ||
                (numa == 6 && numb == 3))
            {
                x = 2;
            }
            else if (
                (numa == 1 && numb == 2) ||
                (numa == 2 && numb == 6) ||
                (numa == 5 && numb == 1) ||
                (numa == 6 && numb == 5))
            {
                x = 3;
            }
            else if (
                (numa == 1 && numb == 5) ||
                (numa == 2 && numb == 1) ||
                (numa == 5 && numb == 6) ||
                (numa == 6 && numb == 2))
            {
                x = 4;
            }
            else if (
                (numa == 1 && numb == 3) ||
                (numa == 3 && numb == 6) ||
                (numa == 4 && numb == 1) ||
                (numa == 6 && numb == 4))
            {
                x = 5;
            }
            else if (
                (numa == 2 && numb == 4) ||
                (numa == 3 && numb == 2) ||
                (numa == 4 && numb == 5) ||
                (numa == 5 && numb == 3))
            {
                x = 6;
            }

            return x;
        }


        public int setTopFront(int a, int b)
        {

            return num[rightNum(reverse[a],reverse[b])];
        }



    }

    class Program
    {
        static void Main()
        {
            var tmp1 = Console.ReadLine().Split(' ');
            var sample1 = new int[tmp1.Length];
            for (int i = 0; i < tmp1.Length; i++)
            {
                sample1[i] = Convert.ToInt32(tmp1[i]);
            }
            Dice a = new Dice(sample1);

            var tmp2 = Console.ReadLine().Split(' ');
            var sample2 = new int[tmp2.Length];
            for (int i = 0; i < tmp2.Length; i++)
            {
                sample2[i] = Convert.ToInt32(tmp2[i]);
            }
            Dice b = new Dice(sample2);

            Boolean ans = true;

            for (int i = 0; i < sample1.Length; i++)
            {
                for (int j = 0; j < sample1.Length; j++)
                {
                    if (a.setTopFront(sample1[i], sample1[j]) != b.setTopFront(sample1[i], sample1[j]))
                    {
                        ans = false;
                    }
                }
            }

            Console.WriteLine(ans?"Yes":"No");

        }
    }
}

Measured memory_bytes: 9004