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

public class Program
{

    public void Proc()
    {
        Dice d1 = new Dice(Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray());
        Dice d2 = new Dice(Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray());
        string ans = "No";
        if(d1.IsSame(d2)) {
            ans = "Yes";
        }
        Console.WriteLine(ans);
    }

    private class Dice {
        DiceState state = new DiceState(1, 2, 3);
        public int[] Label;
        public Dice(int[] label) {
            this.Label = label;
        }
        public int GetTopNum() {
            return this.Label[this.state.Top - 1];
        }
        public void Move(String str) {
            foreach(char c in str) {
                if(c == 'N') {
                    this.state = this.Move(this.state, MoveDir.N);
                } else if(c == 'S') {
                    this.state = this.Move(this.state, MoveDir.S);
                } else if( c== 'E') {
                    this.state = this.Move(this.state, MoveDir.E);
                } else {
                    this.state = this.Move(this.state, MoveDir.W);
				}
            }
        }

        public int GetRightNum(int topNum, int frontNum) {
            int topIdx = this.Label.ToList().IndexOf(topNum) + 1;
            int frontIdx = this.Label.ToList().IndexOf(frontNum) + 1;
            int rightIdx = GetRight(topIdx, frontIdx);
            this.state = new DiceState(topIdx, frontIdx, rightIdx);
            return this.Label[rightIdx - 1];
        }

        public bool IsSame(Dice target) {
            if(!this.Label.All(a=>target.Label.Count(b=>b==a) == this.Label.Count(b=>b==a))) {
                return false;
            }
            if(this.Label.Distinct().Count()<=2) {
                return true;
            }
            int topNum = this.GetTopNum();
            int frontNum = this.Label[this.state.Front - 1];
            int rightNum = this.Label[this.state.Rigt - 1];

            if(rightNum != target.GetRightNum(topNum, frontNum)) {
                return false;
            }
            this.Move("NN");
            target.Move("NN");
            return this.GetTopNum() == target.GetTopNum() && this.Label[this.state.Front - 1] == target.Label[target.state.Front - 1]; 
		}

        public static int GetRight(int top, int front) {
            if((top == 1 && front == 2)||(top == 2 && front == 6) || (top == 6 && front == 5) || (top == 5 && front == 1)) {
                return 3;
            }
            if((top == 1 && front == 3) || (top == 3 && front == 6) || (top == 6 && front == 4) || (top == 4 && front == 1)) {
                return 5;
            }
            if((top == 4 && front == 2) || (top == 2 && front == 3) || (top == 3 && front == 5) || (top == 5 && front == 4)) {
                return 1;
            }
            return 7 - GetRight(front, top);
		}

		private DiceState Move(DiceState current, MoveDir md)
		{
			DiceState ret = new DiceState(current.Top, current.Front, current.Rigt);
			if (md == MoveDir.N)
			{
				ret.Top = current.Front;
				ret.Front = 7 - current.Top;
			}
			if (md == MoveDir.S)
			{
				ret.Top = 7 - current.Front;
				ret.Front = current.Top;
			}
			if (md == MoveDir.E)
			{
				ret.Top = 7 - current.Rigt;
				ret.Rigt = current.Top;
			}
            if (md == MoveDir.W)
			{
				ret.Top = current.Rigt;
				ret.Rigt = 7 - current.Top;
			}
			return ret;
		}


	}


    private struct DiceState {
        public int Top;
        public int Front;
        public int Rigt;
        public DiceState(int t, int f, int r) {
            this.Top = t;
            this.Front = f;
            this.Rigt = r;
        }
    }

    enum MoveDir {
        N,
        S,
        E,
        W
    }

    public class Reader
	{
		private static StringReader sr;
		public static bool IsDebug = false;
		public static string ReadLine()
		{
			if (IsDebug)
			{
				if (sr == null)
				{
					sr = new StringReader(InputText.Trim());
				}
				return sr.ReadLine();
			}
			else
			{
				return Console.ReadLine();
			}
		}
		private static string InputText = @"


1 1 1 1 1 6
1 6 1 1 1 1


";
	}

	public static void Main(string[] args)
	{
#if DEBUG
		Reader.IsDebug = true;
#endif
		Program prg = new Program();
		prg.Proc();
	}
}

Measured memory_bytes: 9908