using System;
using System.Collections.Generic;
using System.Globalization;

enum direction { north, east, west, south }
class dice{
    public int number1;
    public int number2;
    public int me;
    public dice[] east;
    public dice[] north;
    public dice[] south;
    public dice[] west;
    public int[,] direction;
};




class Program
 {
    static public bool match(int dice1, int dice2, dice[] face)
    {
        if ((face[dice1].north[0].number1 == face[dice2].north[0].number2 &
            face[dice1].east[0].number1 == face[dice2].east[0].number2 &
            face[dice1].west[0].number1 == face[dice2].west[0].number2 &
            face[dice1].south[0].number1 == face[dice2].south[0].number2) |
            (face[dice1].north[0].number1 == face[dice2].north[1].number2 &
            face[dice1].east[0].number1 == face[dice2].east[1].number2 &
            face[dice1].west[0].number1 == face[dice2].west[1].number2 &
            face[dice1].south[0].number1 == face[dice2].south[1].number2) |
            (face[dice1].north[0].number1 == face[dice2].north[2].number2 &
            face[dice1].east[0].number1 == face[dice2].east[2].number2 &
            face[dice1].west[0].number1 == face[dice2].west[2].number2 &
            face[dice1].south[0].number1 == face[dice2].south[2].number2) |
            (face[dice1].north[0].number1 == face[dice2].north[3].number2 &
            face[dice1].east[0].number1 == face[dice2].east[3].number2 &
            face[dice1].west[0].number1 == face[dice2].west[3].number2 &
            face[dice1].south[0].number1 == face[dice2].south[3].number2)

            ) return true;
        else return false;
    }

    static void Main(string[] args)
    {
        string nyuryoku;
        dice[] face = new dice[7];
        string [] temp = new string[6];
        for (int i = 1; i < 7; i++)
        {
            face[i] = new dice();
            face[i].east = new dice[4];
            face[i].west = new dice[4];
            face[i].north = new dice[4];
            face[i].south = new dice[4];
            face[i].direction = new int[4,4];
            face[i].me = i;
        }

        face[1].east[0] = face[4];
        face[1].direction[0, 1] = 1;
        face[1].north[0] = face[2];
        face[1].direction[0, 0] = 0;
        face[1].west[0] = face[3];
        face[1].direction[0, 3] = 3;
        face[1].south[0] = face[5];
        face[1].direction[0, 2] = 2;

        face[1].east[1] = face[2];
        face[1].direction[1, 1] = 1;
        face[1].north[1] = face[3];
        face[1].direction[1, 0] = 0;
        face[1].west[1] = face[5];
        face[1].direction[1, 3] = 3;
        face[1].south[1] = face[4];
        face[1].direction[1, 2] = 2;

        face[1].east[2] = face[3];
        face[1].direction[2, 1] = 1;
        face[1].north[2] = face[5];
        face[1].direction[2, 0] = 0;
        face[1].west[2] = face[4];
        face[1].direction[2, 3] = 3;
        face[1].south[2] = face[2];
        face[1].direction[2, 2] = 2;

        face[1].east[3] = face[5];
        face[1].direction[3, 1] = 1;
        face[1].north[3] = face[4];
        face[1].direction[3, 0] = 0;
        face[1].west[3] = face[2];
        face[1].direction[3, 3] = 3;
        face[1].south[3] = face[3];
        face[1].direction[3, 2] = 2;
//--------------------------------------
        face[2].east[0] = face[4];
        face[2].direction[0, 1] = 0;
        face[2].north[0] = face[6];
        face[2].direction[0, 0] = 0;
        face[2].west[0] = face[3];
        face[2].direction[0, 3] = 0;
        face[2].south[0] = face[1];
        face[2].direction[0, 2] = 0;

        face[2].east[1] = face[6];
        face[2].direction[1, 1] = 1;
        face[2].north[1] = face[3];
        face[2].direction[1, 0] = 1;
        face[2].west[1] = face[1];
        face[2].direction[1, 3] = 1;
        face[2].south[1] = face[4];
        face[2].direction[1, 2] = 1;

        face[2].east[2] = face[3];
        face[2].direction[2, 1] = 2;
        face[2].north[2] = face[1];
        face[2].direction[2, 0] = 2;
        face[2].west[2] = face[4];
        face[2].direction[2, 3] = 2;
        face[2].south[2] = face[6];
        face[2].direction[2, 2] = 2;

        face[2].east[3] = face[1];
        face[2].direction[3, 1] = 3;
        face[2].north[3] = face[4];
        face[2].direction[3, 0] = 3;
        face[2].west[3] = face[6];
        face[2].direction[3, 3] = 3;
        face[2].south[3] = face[3];
        face[2].direction[3, 2] = 3;
//--------------------------------------
        face[3].east[0] = face[2];
        face[3].direction[0, 1] = 0;
        face[3].north[0] = face[6];
        face[3].direction[0, 0] = 3;
        face[3].west[0] = face[5];
        face[3].direction[0, 3] = 0;
        face[3].south[0] = face[1];
        face[3].direction[0, 2] = 1;

        face[3].east[1] = face[6];
        face[3].direction[1, 1] = 0;
        face[3].north[1] = face[5];
        face[3].direction[1, 0] = 1;
        face[3].west[1] = face[1];
        face[3].direction[1, 3] = 2;
        face[3].south[1] = face[2];
        face[3].direction[1, 2] = 1;

        face[3].east[2] = face[5];
        face[3].direction[2, 1] = 2;
        face[3].north[2] = face[1];
        face[3].direction[2, 0] = 3;
        face[3].west[2] = face[2];
        face[3].direction[2, 3] = 2;
        face[3].south[2] = face[6];
        face[3].direction[2, 2] = 1;

        face[3].east[3] = face[1];
        face[3].direction[3, 1] = 0;
        face[3].north[3] = face[2];
        face[3].direction[3, 0] = 3;
        face[3].west[3] = face[6];
        face[3].direction[3, 3] = 2;
        face[3].south[3] = face[5];
        face[3].direction[3, 2] = 3;
//-------------------------------------
        face[4].east[0] = face[5];
        face[4].direction[0, 1] = 0;
        face[4].north[0] = face[6];
        face[4].direction[0, 0] = 1;
        face[4].west[0] = face[2];
        face[4].direction[0, 3] = 0;
        face[4].south[0] = face[1];
        face[4].direction[0, 2] = 3;

        face[4].east[1] = face[6];
        face[4].direction[1, 1] = 2;
        face[4].north[1] = face[2];
        face[4].direction[1, 0] = 1;
        face[4].west[1] = face[1];
        face[4].direction[1, 3] = 0;
        face[4].south[1] = face[5];
        face[4].direction[1, 2] = 1;

        face[4].east[2] = face[2];
        face[4].direction[2, 1] = 2;
        face[4].north[2] = face[1];
        face[4].direction[2, 0] = 1;
        face[4].west[2] = face[5];
        face[4].direction[2, 3] = 2;
        face[4].south[2] = face[6];
        face[4].direction[2, 2] = 3;

        face[4].east[3] = face[1];
        face[4].direction[3, 1] = 2;
        face[4].north[3] = face[5];
        face[4].direction[3, 0] = 3;
        face[4].west[3] = face[6];
        face[4].direction[3, 3] = 0;
        face[4].south[3] = face[2];
        face[4].direction[3, 2] = 3;
//------------------------------------
        face[5].east[0] = face[3];
        face[5].direction[0, 1] = 0;
        face[5].north[0] = face[6];
        face[5].direction[0, 0] = 2;
        face[5].west[0] = face[4];
        face[5].direction[0, 3] = 0;
        face[5].south[0] = face[1];
        face[5].direction[0, 2] = 2;

        face[5].east[1] = face[6];
        face[5].direction[1, 1] = 3;
        face[5].north[1] = face[4];
        face[5].direction[1, 0] = 1;
        face[5].west[1] = face[1];
        face[5].direction[1, 3] = 3;
        face[5].south[1] = face[3];
        face[5].direction[1, 2] = 1;

        face[5].east[2] = face[4];
        face[5].direction[2, 1] = 2;
        face[5].north[2] = face[1];
        face[5].direction[2, 0] = 0;
        face[5].west[2] = face[3];
        face[5].direction[2, 3] = 2;
        face[5].south[2] = face[6];
        face[5].direction[2, 2] = 0;

        face[5].east[3] = face[1];
        face[5].direction[3, 1] = 1;
        face[5].north[3] = face[3];
        face[5].direction[3, 0] = 3;
        face[5].west[3] = face[6];
        face[5].direction[3, 3] = 1;
        face[5].south[3] = face[4];
        face[5].direction[3, 2] = 3;
//-----------------------------------
        face[6].east[0] = face[4];
        face[6].direction[0, 1] = 3;
        face[6].north[0] = face[5];
        face[6].direction[0, 0] = 2;
        face[6].west[0] = face[3];
        face[6].direction[0, 3] = 1;
        face[6].south[0] = face[2];
        face[6].direction[0, 2] = 0;

        face[6].east[1] = face[5];
        face[6].direction[1, 1] = 3;
        face[6].north[1] = face[3];
        face[6].direction[1, 0] = 2;
        face[6].west[1] = face[2];
        face[6].direction[1, 3] = 1;
        face[6].south[1] = face[4];
        face[6].direction[1, 2] = 0;

        face[6].east[2] = face[3];
        face[6].direction[2, 1] = 3;
        face[6].north[2] = face[2];
        face[6].direction[2, 0] = 2;
        face[6].west[2] = face[4];
        face[6].direction[2, 3] = 1;
        face[6].south[2] = face[5];
        face[6].direction[2, 2] = 0;

        face[6].east[3] = face[2];
        face[6].direction[3, 1] = 3;
        face[6].north[3] = face[4];
        face[6].direction[3, 0] = 2;
        face[6].west[3] = face[5];
        face[6].direction[3, 3] = 1;
        face[6].south[3] = face[3];
        face[6].direction[3, 2] = 0;
//----------------------------------------
//----------------------------------------

        nyuryoku = Console.ReadLine();
        temp = nyuryoku.Split(' ');
        for (int i = 1; i < 7; i++)
            face[i].number1 = int.Parse(temp[i - 1]);
        nyuryoku = Console.ReadLine();
        temp = nyuryoku.Split(' ');
        for (int i = 1; i < 7; i++)
            face[i].number2 = int.Parse(temp[i - 1]);
        int dice1 = 1,dice2 = 0;

        for (int i = 1; i < 7; i++)
        {
            if (face[dice1].number1 == face[i].number2)
            {
                if (match(dice1, i, face))
                {
                    Console.WriteLine("Yes");
                    return;
                }

            }

        }
                    Console.WriteLine("No");

    }
 }



Measured memory_bytes: 20004