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

namespace AOJ_Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            var oneLine = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var dice = new Dice(oneLine);

            var twoLine = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var dice2 = new Dice(twoLine);

            if (dice.Right == dice2.Front || dice.Left == dice2.Back)
            {
                dice.RotateVertical(Direction.N);
            }
            else if (dice.Left == dice2.Front || dice.Right == dice2.Back)
            {
                dice.RotateVertical(Direction.S);
            }

            for (int i = 0; i < 4; i++)
            {
                if (dice.Top == dice2.Top)
                {
                    break;
                }

                dice.RotateHorizon(Direction.W);
            }


            for (int i = 0; i < 2; i++)
            {
                for (int j = 0; j < 4; j++)
                {
                    if (dice.Top == dice2.Top &&
                        dice.Front == dice2.Front &&
                        dice.Bottom == dice2.Bottom &&
                        dice.Back == dice2.Back)
                    {
                        goto RotateVertical;
                    }
                    dice.RotateHorizon(Direction.N);
                }

                if (dice.Top == dice2.Top &&
                    dice.Front == dice2.Front &&
                    dice.Bottom == dice2.Bottom &&
                    dice.Back == dice2.Back)
                {
                    goto RotateVertical;
                }

                dice.RotateVertical(Direction.N);
                dice.RotateVertical(Direction.N);
            }

            RotateVertical:

            for (int i = 0; i < 4; i++)
            {
                if (dice.Right == dice2.Right &&
                    dice.Back == dice2.Back &&
                    dice.Left == dice2.Left &&
                    dice.Front == dice2.Front)
                {
                    break;
                }
                dice.RotateVertical(Direction.N);
            }

            Console.WriteLine(dice == dice2 ? "Yes" : "No");
        }
    }

    public class Dice
    {
        public int Top { get; private set; }
        public int Right { get; private set; }
        public int Front { get; private set; }
        public int Left { get; private set; }
        public int Bottom { get; private set; }
        public int Back { get; private set; }


        public Dice(IList<int> numbers)
        {
            //this.Number = numbers.ToArray();
            this.Top = numbers[0];
            this.Back = numbers[1];
            this.Right = numbers[2];
            this.Left = numbers[3];
            this.Front = numbers[4];
            this.Bottom = numbers[5];
        }


        public void RotateHorizon(Direction direction)
        {
            var tmp = this.Top;
            switch (direction)
            {
                case Direction.N:
                    this.Top = this.Back;
                    this.Back = this.Bottom;
                    this.Bottom = this.Front;
                    this.Front = tmp;
                    break;
                case Direction.E:
                    this.Top = this.Left;
                    this.Left = this.Bottom;
                    this.Bottom = this.Right;
                    this.Right = tmp;
                    break;
                case Direction.W:
                    this.Top = this.Right;
                    this.Right = this.Bottom;
                    this.Bottom = this.Left;
                    this.Left = tmp;
                    break;
                case Direction.S:
                    this.Top = this.Front;
                    this.Front = this.Bottom;
                    this.Bottom = this.Back;
                    this.Back = tmp;
                    break;
                default:
                    break;
            }
        }

        public void RotateVertical(Direction direction)
        {
            var tmp = this.Right;
            switch (direction)
            {
                case Direction.N:
                    this.Right = this.Back;
                    this.Back = this.Left;
                    this.Left = this.Front;
                    this.Front = tmp;
                    break;
                case Direction.S:
                    this.Right = this.Front;
                    this.Front = this.Left;
                    this.Left = this.Back;
                    this.Back = tmp;
                    break;
                default:
                    break;
            }
        }

        public static bool operator ==(Dice d, Dice d2)
        {
            return d.Top == d2.Top &&
                   d.Right == d2.Right &&
                   d.Bottom == d2.Bottom &&
                   d.Left == d2.Left &&
                   d.Front == d2.Front &&
                   d.Back == d2.Back;
        }

        public static bool operator !=(Dice d, Dice d2)
        {
            return !(d == d2);
        }
    }

    /// <summary>
    /// ダイスを転がす方向
    /// </summary>
    public enum Direction
    {
        N,
        E,
        W,
        S
    }

}



Measured memory_bytes: 20464