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

class Program
{
    public class dice
    {
        public int n, e, w, s, t, b;
        private int ni, ei, wi, si, ti, bi;
        public dice(int t, int s, int e, int w, int n, int b)
        {
            this.n = n;
            this.e = e;
            this.w = w;
            this.s = s;
            this.t = t;
            this.b = b;
            ni = n;
            ei = e;
            wi = w;
            si = s;
            ti = t;
            bi = b;
        }
        public void init()
        {
            n = ni;
            e = ei;
            w = wi;
            s = si;
            t = ti;
            b = bi;
        }
        public void rotateCW()
        {
            int buf = s;
            s = e;
            e = n;
            n = w;
            w = buf;
        }
        public bool same(dice dice)
        {
            return (n == dice.n && e == dice.e && w == dice.w && s == dice.s && t == dice.t && b == dice.b);
        }
        public void roll(char r)
        {
            int buf;
            switch (r)
            {
                case 'N':
                    buf = t;
                    t = s;
                    s = b;
                    b = n;
                    n = buf;
                    break;

                case 'E':
                    buf = t;
                    t = w;
                    w = b;
                    b = e;
                    e = buf;
                    break;

                case 'W':
                    buf = t;
                    t = e;
                    e = b;
                    b = w;
                    w = buf;
                    break;

                case 'S':
                    buf = t;
                    t = n;
                    n = b;
                    b = s;
                    s = buf;
                    break;
            }
        }
    }
    static void Main(string[] args)
    {
        int[][] d = io.r<int>(2, ' ');
        dice dice1 = new dice(d[0][0], d[0][1], d[0][2], d[0][3], d[0][4], d[0][5]);
        dice dice2 = new dice(d[1][0], d[1][1], d[1][2], d[1][3], d[1][4], d[1][5]);
        bool f = false;
        for (int i = 0; i < 4; i++)
        {
            for (int j = 0; j < 4; j++)
            {
                dice1.init();
                for (int k = 0; k < i; k++) { dice1.rotateCW(); }
                for (int k = 0; k < j; k++) { dice1.roll('N'); }
                while (true)
                {
                    if (dice2.t == dice1.t) { break; }
                    dice2.roll('N');
                    if (dice2.t == dice1.t) { break; }
                    dice2.roll('E');
                }
                for (int k = 0; k < 4; k++)
                {
                    if (dice2.s == dice1.s) { break; }
                    dice2.rotateCW();
                }
                if (dice1.same(dice2)) { f = true; break; }
            }
        }
        if (f) { io.w("Yes"); } else { io.w("No"); }
        io.wflush();
    }
}

namespace LIB
{
    public class io
    {
        private const int WMAX = 1000;
        private static StringBuilder S = new StringBuilder();
        public static T r<T>() { return util.parse<T>(r()); }
        public static T[] r<T>(char s = ' ') { return r().Split(s).Select(util.parse<T>).ToArray(); }
        public static T[] r<T>(int l) { T[] r = new T[l]; for (int i = 0; i < l; i++) { r[i] = r<T>(); } return r; }
        public static T[][] r<T>(int l, char s = ' ') { T[][] r = new T[l][]; for (int i = 0; i < l; i++) { r[i] = r<T>(s); } return r; }
        private static string r() { return Console.ReadLine(); }
        public static void w(object v, bool lf = true) { S.Append(util.parse<string>(v)); if (lf == true) { S.Append('\n'); } if (S.Length >= WMAX) { wflush(); } }
        public static void wflush() { Console.Write(S.ToString()); S.Length = 0; }
    }
    public class util
    {
        public static T parse<T>(object value) { return (T)(Convert.ChangeType(value, typeof(T))); }
    }
    public class memo<Key, Result>
    {
        private Dictionary<Key, Result> R;
        public memo() { R = new Dictionary<Key, Result>(); }
        public Result exec(Key k, Func<Key, Result> f) { Result r; if (R.ContainsKey(k)) { r = R[k]; } else { r = f(k); R.Add(k, r); } return r; }
    }
}

Measured memory_bytes: 10396