#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <set>

using namespace std;

class Dice {
    int s1, s2, s3, s4, s5, s6;

public:
    Dice(int s1, int s2, int s3, int s4, int s5, int s6);

    void print();

    void relocate(int top, int front);

    void roll(char F);

    bool make_top(int top);

    bool make_front(int front);

    void print(int side);

    int get(int side);
};

bool Dice::make_top(int top) {
    bool res = true;
    if (s1 == top) {}
    else if (s2 == top) {
        roll('N');
    } else if (s3 == top) {
        roll('W');
    } else if (s4 == top) {
        roll('E');
    } else if (s5 == top) {
        roll('S');
    } else if (s6 == top) {
        roll('N');
        roll('N');
    } else {
        res = false;
    }
    return res;
}

bool Dice::make_front(int front) {
    if (front == s2) return true;
    else if (front == s6 || front == s1) return false;
    else roll('R');
    bool res = make_front(front);
    return res;
}

void Dice::relocate(int top, int front) {
    vector<int> S{s1, s2, s3, s4, s5, s6};
    int top_idx = distance(S.begin(), find(S.begin(), S.end(), top));
    int front_idx = distance(S.begin(), find(S.begin(), S.end(), front));

    int tmp_s1 = s1;
}

void Dice::roll(char F) {
    int tmp = s1;
    if (F == 'N') {
        s1 = s2;
        s2 = s6;
        s6 = s5;
        s5 = tmp;
    } else if (F == 'W') {
        s1 = s3;
        s3 = s6;
        s6 = s4;
        s4 = tmp;
    } else if (F == 'S') {
        s1 = s5;
        s5 = s6;
        s6 = s2;
        s2 = tmp;
    } else if (F == 'E') {
        s1 = s4;
        s4 = s6;
        s6 = s3;
        s3 = tmp;
    } else if (F == 'R') {
        tmp = s2;
        s2 = s3;
        s3 = s5;
        s5 = s4;
        s4 = tmp;
    } else {
        cout << "unknown command: " << F << endl;
    }
}

void Dice::print() {
    cout << s1 << endl;
}

void Dice::print(int side) {
    vector<int> S{s1, s2, s3, s4, s5, s6};
    cout << S[side - 1] << endl;
}

int Dice::get(int side) {
    vector<int> S{s1, s2, s3, s4, s5, s6};
    return S[side - 1];
}


Dice::Dice(int _s1, int _s2, int _s3, int _s4, int _s5, int _s6) {
    s1 = _s1;
    s2 = _s2;
    s3 = _s3;
    s4 = _s4;
    s5 = _s5;
    s6 = _s6;
}

int main() {
    int s, S[6], T[6];
    set<int> set_s, set_t;

    for (int i = 0; i < 6; i++) {
        cin >> S[i];
        set_s.insert(S[i]);
    }
    for (int i = 0; i < 6; i++) {
        cin >> T[i];
        set_t.insert(T[i]);
    }

    if (set_s != set_t) {
        cout << "No" << endl;
        return 0;
    }
//    string str;
//    cin >> str;
//    for (int i = 0; i < str.length(); i++) {
//        dice.roll(str[i]);
//    }
//    dice.print();



    Dice d1 = Dice(S[0], S[1], S[2], S[3], S[4], S[5]);
    Dice d2 = Dice(T[0], T[1], T[2], T[3], T[4], T[5]);

    bool ans;
    for (int i = 1; i <= 6; i++) {
        Dice d1 = Dice(S[0], S[1], S[2], S[3], S[4], S[5]);
        Dice d2 = Dice(T[0], T[1], T[2], T[3], T[4], T[5]);

        int top = d2.get(i);
        ans = d1.make_top(top);
        ans = ans && d2.make_top(top);

        if (ans) {
            if (i == 6)d1.make_front(d2.get(1));
            else d1.make_front(d2.get(i + 1));
        }


        for (int j = 1; j <= 6; j++) {
            ans = ans && d1.get(j) == d2.get(j);
        }
        if (ans)break;
    }

    if (ans) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 3120