#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <ctype.h>
#include <algorithm>
#include <cmath>

#define REP(i, n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define square(x) (x) * (x)
#define cube(x) (x) * (x) * (x)

const int INF = 1e9;

using namespace std;

class dice{
    private:
    int s[6];
    int top;
    int bottom;
    int r_side;
    int l_side;
    int face;
    int rev;

    public:
    dice(){
        top = 0;
        bottom = 5;
        r_side = 2;
        l_side = 3;
        face = 1;
        rev = 4;
        s[0] = 1;
        s[1] = 2;
        s[2] = 3;
        s[3] = 4;
        s[4] = 5;
        s[5] = 6;
    }

    dice(int a[5]){
        top = 0;
        bottom = 5;
        r_side = 2;
        l_side = 3;
        face = 1;
        rev = 4;
        REP(i, 6) s[i] = a[i];
    }

    dice(int x, int y, int z, int u, int v, int w){
        top = 0;
        bottom = 5;
        r_side = 2;
        l_side = 3;
        face = 1;
        rev = 4;
        s[0] = x;
        s[1] = y;
        s[2] = z;
        s[3] = u;
        s[4] = v;
        s[5] = w;
    }

    int get_top() {
        return s[top];
    }

    int get_bottom(){
        return s[bottom];
    }

    int get_r_side(){
        return s[r_side];
    }

    int get_l_side(){
        return s[l_side];
    }

    int get_face(){
        return s[face];
    }

    int get_rev(){
        return s[rev];
    }

    int set_top(int i) {
        top = i;
        bottom = 5 - top;
        r_side = (i+1)%5;
        l_side = 5 - r_side;
        face = (i+2)%5;
        rev = 5 - face;
        return s[top];
    }

    int rotate_r(int i) {
        while(i<0)
            i+=4;
        i %= 4;
        REP(j, i){
            int temp = face;
            face = r_side;
            r_side = rev;
            rev = l_side;
            l_side = temp;
        }
        return s[top];
    }

    int roll_r(int i) {
        while(i<0)
            i+=4;
        i %= 4;
        REP(j, i){
            int temp = top;
            top = l_side;
            l_side = bottom;
            bottom = r_side;
            r_side = temp;
        }
        return s[top];
    }

    int roll_f(int i){
        while(i<0)
            i+=4;
        i %= 4;
        REP(j, i){
            int temp = top;
            top = face;
            face = bottom;
            bottom = rev;
            rev = temp;
        }
        return s[top];
    }

};

dice search(int t, int f, dice d) {
    while(d.get_top() != t || d.get_face() != f){
        if(d.get_top() == t){
            while(d.get_face() != f)
                d.rotate_r(1);
            break;
        }
        else if(d.get_face() == f){
            while(d.get_top() != t)
                d.roll_r(1);
            break;
        }
        else {
            REP(i, 4){
                d.roll_f(1);
                if(d.get_face() == f || d.get_top() == t)
                    break;
            }
            if(d.get_face() != f && d.get_top() != t)
                return dice(-1, 0, 0, 0, 0, 0);
        }
    }
    return d;
}

int main() {
    int in1[6];
    int in2[6];
    bool b = false;
    REP(i, 6) cin >> in1[i];
    REP(i, 6) cin >> in2[i];
    dice d1 = dice(in1);
    dice d2 = dice(in2);
    REP(i, 6) {
        if(d1.get_top() != d1.get_face())
            break;
        d1.set_top(i);
    }
    d2 = search(d1.get_top(), d1.get_face(), d2);
    if(d2.get_top() < 0 || d1.get_l_side() != d2.get_l_side() || d1.get_rev() != d2.get_rev() || d1.get_bottom() != d2.get_bottom())
        cout << "No" << endl;
    else
        cout << "Yes" << endl;


    return 0;
}

Measured memory_bytes: 1156