#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

class dice {
private:
    const int default_face[6] = { 1,6,4,5,3,2 }; //天一地六東五西二南三北四
    vector<int> face;
    void _roll(int a, int b, int c, int d) {
        int t = face[a];
        face[a] = face[b];
        face[b] = face[c];
        face[c] = face[d];
        face[d] = t;
    }

public:
    enum { TOP, BOTTOM, NORTH, EAST, SOUTH, WEST };

    dice() : face(6) { set_default(); }
    dice(const dice& src) { *this = src; }
    ~dice() {}

    dice& operator=(const dice& src) {
        face = src.face;
        return *this;        
    }
    bool operator==(const dice& d) const {
        return face == d.face;
    }

    void set_default() {
        set_face(default_face);
    }
    void set_face(vector<int>& face /* 0:top, 1:bottom, 2:north, 3:east, 4:south, 5:west */) {
        this->face = face;
    }
    void set_face(const int face[]) {
        for (int i = 0; i < 6; i++) this->face[i] = face[i];
    }
    void set_face(int t, int b, int n, int e, int s, int w) {
        face[TOP] = t; face[BOTTOM] = b; face[NORTH] = n;
        face[EAST] = e; face[SOUTH] = s; face[WEST] = w;
    }
    int get_face(int dir) const { return face[dir]; }

    int top() const { return get_face(TOP); }
    int bottom() const { return get_face(BOTTOM); }
    int north() const { return get_face(NORTH); }
    int east() const { return get_face(EAST); }
    int south() const { return get_face(SOUTH); }
    int west() const { return get_face(WEST); }

    void roll_north() { _roll(NORTH, TOP, SOUTH, BOTTOM); }
    void roll_south() { _roll(SOUTH, TOP, NORTH, BOTTOM); }
    void roll_east() { _roll(EAST, TOP, WEST, BOTTOM); }
    void roll_west() { _roll(WEST, TOP, EAST, BOTTOM); }

    void turn_clockwise() { _roll(NORTH, WEST, SOUTH, EAST); }
    void turn_counterclockwise() { _roll(NORTH, EAST, SOUTH, WEST); }

    void debug_print() const {
        cout << "top: "     << face[TOP]
             << ", bottom: "<< face[BOTTOM]
             << ", north: " << face[NORTH]
             << ", east: "  << face[EAST]
             << ", south: " << face[SOUTH]
             << ", west: "  << face[WEST] << endl;
    }
    bool equivalent(dice d) const {
        for (int i = 0; i < 6; i++) {
            for (int j = 0; j < 4; j++) {
                if (*this == d) return true;                
                d.turn_clockwise();
            }
            i % 2 ? d.roll_west() : d.roll_north();
        }
        return false;
    }
    bool north_up(int north, int top) {
        dice d(*this);
        for (int i = 0; i < 6; i++) {
            for (int j = 0; j < 4; j++) {
                if (d.north() == north && d.top() == top) {
                    *this = d;
                    return true;                
                }
                d.turn_clockwise();
            }
            i % 2 ? d.roll_west() : d.roll_north();
        }
        return false;
    }
};

int main()
{
    dice d1, d2;
    vector<int> n(6);
    
    for (int i = 0; i < 6; i++) cin >> n[i];
    d1.set_face(n[0], n[5], n[4], n[2], n[1], n[3]);

    for (int i = 0; i < 6; i++) cin >> n[i];
    d2.set_face(n[0], n[5], n[4], n[2], n[1], n[3]);

    cout << (d1.equivalent(d2) ? "Yes":"No") << endl;
    
}



Measured memory_bytes: 3148