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

class Dice
{
    public int[] Number { get; set; }

    private int[] tmp = new int[6];

    public void SetNumber(int[] a)
    {
        for (int i = 0; i < 6; i++)
        {
            Number[i] = a[i];
        }
    }

    public void Rotate(char c)
    {

        switch (c)
        {
            case 'N':
                tmp[0] = Number[1];
                tmp[1] = Number[5];
                tmp[2] = Number[2];
                tmp[3] = Number[3];
                tmp[4] = Number[0];
                tmp[5] = Number[4];
                SetNumber(tmp);
                break;
            case 'E':
                tmp[0] = Number[3];
                tmp[1] = Number[1];
                tmp[2] = Number[0];
                tmp[3] = Number[5];
                tmp[4] = Number[4];
                tmp[5] = Number[2];
                SetNumber(tmp);
                break;
            case 'W':
                tmp[0] = Number[2];
                tmp[1] = Number[1];
                tmp[2] = Number[5];
                tmp[3] = Number[0];
                tmp[4] = Number[4];
                tmp[5] = Number[3];
                SetNumber(tmp);
                break;
            case 'S':
                tmp[0] = Number[4];
                tmp[1] = Number[0];
                tmp[2] = Number[2];
                tmp[3] = Number[3];
                tmp[4] = Number[5];
                tmp[5] = Number[1];
                SetNumber(tmp);
                break;
            default:
                break;
        }
    }

    public void Spin()
    {
        tmp[0] = Number[0];
        tmp[1] = Number[2];
        tmp[2] = Number[4];
        tmp[3] = Number[1];
        tmp[4] = Number[3];
        tmp[5] = Number[5];
        SetNumber(tmp);
    }

    public void SetTop(int a)
    {
        if (a == Number[0])
        {

        }
        else if (a == Number[1])
        {
            Rotate('N');
        }
        else if (a == Number[2])
        {
            Rotate('W');
        }
        else if (a == Number[3])
        {
            Rotate('E');
        }
        else if (a == Number[4])
        {
            Rotate('S');
        }
        else if (a == Number[5])
        {
            Rotate('N');
            Rotate('N');
        }
    }

    public void SetFront(int a)
    {
        if (a == Number[0])
        {
            Rotate('S');
        }
        else if (a == Number[1])
        {
        }
        else if (a == Number[2])
        {
            Spin();
        }
        else if (a == Number[3])
        {
            Spin();
            Spin();
            Spin();
        }
        else if (a == Number[4])
        {
            Spin();
            Spin();
        }
        else if (a == Number[5])
        {
            Rotate('N');
        }
    }

    public static bool Equals(Dice x, Dice y)
    {
        y.SetTop(x.Number[0]);
        y.SetFront(x.Number[1]);
        for (int i = 0; i < 6; i++)
        {
            if (x.Number[i] != y.Number[i])
            {
                return false;
            }
        }
        return true;
    }
}

class MyClass
{
    public static void Main(string[] args)
    {
        var dice1 = new Dice()
        { Number = Console.ReadLine().Split().Select(int.Parse).ToArray() };
        var dice2 = new Dice()
        { Number = Console.ReadLine().Split().Select(int.Parse).ToArray() };
        Console.WriteLine(Dice.Equals(dice1,dice2) ? "Yes" : "No");
    }
}


Measured memory_bytes: 20240