#include <bits/stdc++.h>
#include <chrono>
using namespace std;

using _i64 = int64_t;
using _u64 = uint64_t;
using _f64 = double;

#define _for(i, start, end) for(_i64 i = (_i64)start; i < (_i64)end; ++i)
#define _rep(i, number) _for(i, 0, number)
#define _foreach(e, data) for(auto& e : data)
#define _all(data) data.begin(), data.end()

template<typename type>
_i64 _size(const type& data) { return static_cast<_i64>(data.size()); }
template<typename type, size_t size>
_i64 _size(const type (&)[size]) { return static_cast<_i64>(size); }

enum _flag : bool { able = true, disable = false };

struct _time {
    _time(_flag flag) { check = flag; if(!check) { return; } gettime(start); }
    ~_time() {
        if(!check) { return; }; gettime(end);
        _i64 elapse = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cout << endl << "Time: " << elapse << " ms" << endl;
    }
    private:
    using _timer = chrono::time_point<chrono::system_clock>;
    _timer start, end; bool check;
    void gettime(_timer& time) { time = chrono::system_clock::now(); }
};

struct _ini { _ini() { ios::sync_with_stdio(false); cin.tie(nullptr); } } _ini;

struct _dice {
    _i64 pip1, pip2, pip3, pip4, pip5, pip6;
    void pipget() { cin >> pip1 >> pip2 >> pip3 >> pip4 >> pip5 >> pip6; }
    void move(string order) {
        _i64 _pip1, _pip2, _pip3, _pip4, _pip5, _pip6;
        _foreach(e, order) {
            _pip1 = pip1; _pip2 = pip2; _pip3 = pip3; _pip4 = pip4; _pip5 = pip5; _pip6 = pip6;
            switch(e) {
                case 'E': pip1 = _pip4; pip3 = _pip1; pip6 = _pip3; pip4 = _pip6; break;
                case 'N': pip1 = _pip2; pip2 = _pip6; pip6 = _pip5; pip5 = _pip1; break;
                case 'S': pip1 = _pip5; pip2 = _pip1; pip6 = _pip2; pip5 = _pip6; break;
                case 'W': pip1 = _pip3; pip3 = _pip6; pip6 = _pip4; pip4 = _pip1; break;
            }
        }
    }
    void rotate(string order) {
        _i64 _pip1, _pip2, _pip3, _pip4, _pip5, _pip6;
        _foreach(e, order) {
            _pip1 = pip1; _pip2 = pip2; _pip3 = pip3; _pip4 = pip4; _pip5 = pip5; _pip6 = pip6;
            switch(e) {
                case 'C': pip2 = _pip3; pip3 = _pip5; pip5 = _pip4; pip4 = _pip2; break;
                case 'A': pip2 = _pip4; pip3 = _pip2; pip5 = _pip3; pip4 = _pip5; break;
            }
        }
    }
    void decide(_i64 label1, _i64 info1, _i64 label2, _i64 info2) {
        _dice copy;
        copy.pip1 = pip1; copy.pip2 = pip2; copy.pip3 = pip3;
        copy.pip4 = pip4; copy.pip5 = pip5; copy.pip6 = pip6;
        _rep(i, 13) {
            switch(i) {
                case 0: break;
                case 1: copy.move("N"); break;
                case 2: copy.move("N"); break;
                case 3: copy.move("N"); break;
                case 4: copy.move("N"); break;
                case 5: copy.move("E"); break;
                case 6: copy.move("E"); break;
                case 7: copy.move("E"); break;
                case 8: copy.move("E"); break;
                case 9: copy.rotate("C"); break;
                case 10: copy.rotate("C"); break;
                case 11: copy.rotate("C"); break;
                case 12: copy.rotate("C"); break;
            }
            if(copy.pipinfo(label1) == info1) {
                if(label1 == 1 || label1 == 6) {
                    _rep(i, 4) {
                        switch(i) {
                            case 0: break;
                            case 1: copy.rotate("C"); break;
                            case 2: copy.rotate("C"); break;
                            case 3: copy.rotate("C"); break;
                        }
                        if(copy.pipinfo(label2) == info2) { break; }
                    }
                }
                else if(label1 == 2 || label1 == 5) {
                    _rep(i, 4) {
                        switch(i) {
                            case 0: break;
                            case 1: copy.move("E"); break;
                            case 2: copy.move("E"); break;
                            case 3: copy.move("E"); break;
                        }
                        if(copy.pipinfo(label2) == info2) { break; }
                    }
                }
                else if(label1 == 3 || label1 == 4) {
                    _rep(i, 4) {
                        switch(i) {
                            case 0: break;
                            case 1: copy.move("N"); break;
                            case 2: copy.move("N"); break;
                            case 3: copy.move("N"); break;
                        }
                        if(copy.pipinfo(label2) == info2) { break; }
                    }
                }
            }
            if(copy.pipinfo(label2) == info2) { break; }
        }
        pip1 = copy.pip1; pip2 = copy.pip2; pip3 = copy.pip3;
        pip4 = copy.pip4; pip5 = copy.pip5; pip6 = copy.pip6;
    }
    bool operator==(const _dice& rhs) const {
        _dice copy = rhs;
        if(pip1 != pip6) {
            copy.decide(1, pip1, 6, pip6);
            _rep(i, 4) {
                switch(i) {
                    case 0: break;
                    case 1: copy.rotate("C"); break;
                    case 2: copy.rotate("C"); break;
                    case 3: copy.rotate("C"); break;
                }
                if(issame(copy)) { break; }
            }
        }
        else if(pip2 != pip5) {
            copy.decide(2, pip2, 5, pip5);
            _rep(i, 4) {
                switch(i) {
                    case 0: break;
                    case 1: copy.move("E"); break;
                    case 2: copy.move("E"); break;
                    case 3: copy.move("E"); break;
                }
                if(issame(copy)) { break; }
            }
        }
        else if(pip3 != pip4){
            copy.decide(3, pip3, 4, pip4);
            _rep(i, 4) {
                switch(i) {
                    case 0: break;
                    case 1: copy.move("N"); break;
                    case 2: copy.move("N"); break;
                    case 3: copy.move("N"); break;
                }
                if(issame(copy)) { break; }
            }
        }
        return issame(copy);
    }
    private:
    _i64 pipinfo(_i64 number) const {
        switch(number) {
            case 1: return pip1; case 2: return pip2; case 3: return pip3;
            case 4: return pip4; case 5: return pip5; case 6: return pip6;
        }
    }
    bool issame(_dice dice) const {
        _for(i, 1, 7) { if(pipinfo(i) != dice.pipinfo(i)) { return false; } }
        return true;
    }
};

int main() {
    {
        _time time(disable);
        _dice dice1, dice2;
        dice1.pipget(); dice2.pipget();
        cout << (dice1 == dice2 ? "Yes" : "No") << endl;
    }
    return 0;
}


Measured memory_bytes: 3240