#include <iostream>
using namespace std;

class Dice {
public:
    int label1;
    int label2;
    int label3;
    int label4;
    int label5;
    int label6;

    Dice() {
        label1 = 0;
        label2 = 0;
        label3 = 0;
        label4 = 0;
        label5 = 0;
        label6 = 0;
    }

    int getValue(int label) {
        switch (label) {
        case 1: return label1; break;
        case 2: return label2; break;
        case 3: return label3; break;
        case 4: return label4; break;
        case 5: return label5; break;
        case 6: return label6; break;
        default: break;
        }
        return -1;
    }

    void setValue(int n, int l) {
        switch (l) {
        case 1: label1 = n; break;
        case 2: label2 = n; break;
        case 3: label3 = n; break;
        case 4: label4 = n; break;
        case 5: label5 = n; break;
        case 6: label6 = n; break;
        default: break;
        }
    }

    void roll(char c) {
        int a = label1;
        int b = label2;
        switch (c) {
        case 'N':            
            label1 = label2;
            label2 = label6;
            label6 = label5;
            label5 = a;                
            break;
        case 'S':
            label1 = label5;
            label5 = label6;
            label6 = label2;
            label2 = a;
            break;
        case 'W':
            label1 = label3;
            label3 = label6;
            label6 = label4;
            label4 = a;
            break;
        case 'E':
            label1 = label4;
            label4 = label6;
            label6 = label3;
            label3 = a;
            break;
        case 'R':
            label2 = label3;
            label3 = label5;
            label5 = label4;
            label4 = b;
            break;
        default: 
            break;
        }
    }
    int FindLabel(int n) {
        if (label1 == n) return 1;
        if (label2 == n) return 2;
        if (label3 == n) return 3;
        if (label4 == n) return 4;
        if (label5 == n) return 5;
        if (label6 == n) return 6;
        return -1;
    }

public:
    bool operator ==(const Dice& rhs) const
    {
        return (label1 == rhs.label1
            && label2 == rhs.label2
            && label3 == rhs.label3
            && label4 == rhs.label4
            && label5 == rhs.label5
            && label6 == rhs.label6
            );
    }

    bool operator !=(const Dice& rhs) const
    {
        return (label1 != rhs.label1
            || label2 != rhs.label2
            || label3 != rhs.label3
            || label4 != rhs.label4
            || label5 != rhs.label5
            || label6 != rhs.label6
            );
    }
 };

int main()
{
    Dice DiceA;

    for (int i = 0; i < 6; i++) {
        int n = 0;
        cin >> n;
        DiceA.setValue(n, i + 1);
    }

    Dice DiceB;
    for (int i = 0; i < 6; i++) {
        int n = 0;
        cin >> n;
        DiceB.setValue(n, i + 1);
    }

    int l1 = DiceA.FindLabel(DiceB.label1);
    int l2 = DiceA.FindLabel(DiceB.label2);
    if (l1 < 0 || l2 < 0) cout << "No" << endl;
    else {
        bool bSame = false;
        if (DiceA == DiceB) bSame = true;
        for (int i = 0; i < 4; i++) {
            DiceB.roll('N');
            for (int j = 0; j < 4; j++) {
                DiceB.roll('R');
                if (DiceA == DiceB) bSame = true;
            }
        }
        DiceB.roll('W');
        for (int i = 0; i < 4; i++) {
            DiceB.roll('R');
            if (DiceA == DiceB) bSame = true;
        }
        DiceB.roll('W');
        DiceB.roll('W');
        for (int i = 0; i < 4; i++) {
            DiceB.roll('R');
            if (DiceA == DiceB) bSame = true;
        }

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


Measured memory_bytes: 3120