using System;

class program
{

    public static void Main()
    {
        var faces = new int[6];
        var nums = Console.ReadLine().Split(' ');

        for (var i = 0; i < 6; i++)
        {
            faces[i] = int.Parse(nums[i]);
        }

        var dice1 = new Dice(faces);

        nums = Console.ReadLine().Split(' ');

        for (var i = 0; i < 6; i++)
        {
            faces[i] = int.Parse(nums[i]);
        }

        var dice2 = new Dice(faces);

        if (dice1.Equal(dice2))
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }

    }
}

public class Dice
{
    public int front { get; set; }
    private int back { get; set; } // rear
    private int up { get; set; }
    private int down { get; set; }
    private int left { get; set; }
    private int right { get; set; }

    public Dice(int[] faces)
    {
        this.front = faces[0];
        this.down = faces[1];
        this.right = faces[2];
        this.left = faces[3];
        this.up = faces[4];
        this.back = faces[5];
    }

    public int findRightNum(int front, int down)
    {
        for (int i = 0; i < 5; i++)
        {
            if (front == this.front) break;

            if (i < 3) // 0..2
            {
                doE();
            }
            else if (i == 3)
            {
                doN();
            }
            else // 4
            {
                doS(); doS();
            }

        }

        for (int i = 0; i < 3; i++)
        {
            if (down == this.down) break;
            doRotateR();
        }

        return this.right;
    }

    public void next(string command)
    {
        switch (command)
        {
            case "N":
                doN();
                break;
            case "E":
                doE();
                break;
            case "S":
                doS();
                break;
            case "W":
                doW();
                break;
        }
    }

    private void doN()
    {
        var buf = this.down;
        this.down = this.back;
        this.back = this.up;
        this.up = this.front;
        this.front = buf;
    }

    private void doE()
    {
        var buf = this.left;
        this.left = this.back;
        this.back = this.right;
        this.right = this.front;
        this.front = buf;
    }

    private void doS()
    {
        var buf = this.up;
        this.up = this.back;
        this.back = this.down;
        this.down = this.front;
        this.front = buf;
    }

    private void doW()
    {
        var buf = this.right;
        this.right = this.back;
        this.back = this.left;
        this.left = this.front;
        this.front = buf;
    }

    private void doRotateR()
    {
        var buf = this.up;
        this.up = this.left;
        this.left = this.down;
        this.down = this.right;
        this.right = buf;
    }

    public bool Equal(Dice dice)
    {
        for (int i = 0; i < 5; i++)
        {
            for (int j = 0; j < 4; j++)
            {
                dice.doRotateR();
                if (EqualDice(dice))
                {
                    return true;
                }
            };

            if (i < 3) // 0..2
            {
                doE();
                for (int j = 0; j < 4; j++) { 
                    dice.doRotateR(); 
                    if (EqualDice(dice)) { 
                        return true; 
                    } 
                };
            }
            else if (i == 3)
            {
                doN();
                for (int j = 0; j < 4; j++)
                {
                    dice.doRotateR();
                    if (EqualDice(dice))
                    {
                        return true;
                    }
                };
            }
            else // 4
            {
                doS(); doS();
                for (int j = 0; j < 4; j++)
                {
                    dice.doRotateR();
                    if (EqualDice(dice))
                    {
                        return true;
                    }
                };
            }
        }
        return false;
    }

    public bool EqualDice(Dice dice)
    {
        if (this.front == dice.front &&
            this.left == dice.left &&
            this.right == dice.right &&
            this.down == dice.down &&
            this.up == dice.up &&
            this.back == dice.back)
        {
            return true;
        }

        return false;
    }
}

Measured memory_bytes: 5332