#include <iostream>
#include <vector>
 
class Dice
{
public:
    Dice(int v1, int v2, int v3, int v4, int v5, int v6);
    void rollE();
    void rollN();
    void rollS();
    void rollW();
    void rollR();
    void rollL();
    bool rollToTop(int s);
    bool rollToFrontHorizontal(int s);
    int getTop();
    int getRight();
    int getFront();
    bool operator==(const Dice& rhs) const;
private:
    int ms1, ms2, ms3, ms4, ms5, ms6;
    std::vector<int> mvlist;
};
 
Dice::Dice(int v1, int v2, int v3, int v4, int v5, int v6)
: ms1(1), ms2(2), ms3(3), ms4(4), ms5(5), ms6(6)
{
    mvlist.reserve(6);
    mvlist.push_back(v1);
    mvlist.push_back(v2);
    mvlist.push_back(v3);
    mvlist.push_back(v4);
    mvlist.push_back(v5);
    mvlist.push_back(v6);
}

void Dice::rollE() {
    int tmp = ms1;
    ms1 = ms4;
    ms4 = ms6;
    ms6 = ms3;
    ms3 = tmp;
}
 
void Dice::rollN() {
    int tmp = ms1;
    ms1 = ms2;
    ms2 = ms6;
    ms6 = ms5;
    ms5 = tmp;
}
 
void Dice::rollS() {
    int tmp = ms1;
    ms1 = ms5;
    ms5 = ms6;
    ms6 = ms2;
    ms2 = tmp;
}
 
void Dice::rollW() {
    int tmp = ms1;
    ms1 = ms3;
    ms3 = ms6;
    ms6 = ms4;
    ms4 = tmp;
}
 
void Dice::rollR() {
    int tmp = ms2;
    ms2 = ms4;
    ms4 = ms5;
    ms5 = ms3;
    ms3 = tmp;
}
 
void Dice::rollL() {
    int tmp = ms2;
    ms2 = ms3;
    ms3 = ms5;
    ms5 = ms4;
    ms4 = tmp;
}
 
bool Dice::rollToTop(int s) {
    bool ret = true;
    if (s == ms1) {
        // NOP
    } else if (s == ms2) {
        rollN();
    } else if (s == ms3) {
        rollW();
    } else if (s == ms4) {
        rollE();
    } else if (s == ms5) {
        rollS();
    } else if (s == ms6) {
        rollN();
        rollN();
    } else {
        ret = false;
    }
    return ret;
}
 
bool Dice::rollToFrontHorizontal(int s) {
    bool ret = true;
    if (s == ms1) {
        ret = false;
    } else if (s == ms2) {
        // NOP
    } else if (s == ms3) {
        rollL();
    } else if (s == ms4) {
        rollR();
    } else if (s == ms5) {
        rollR();
        rollR();
    } else if (s == ms6) {
        ret = false;
    } else {
        ret = false;
    }
    return ret;
}
 
int Dice::getTop() {
    return mvlist[ms1 - 1];
}
 
int Dice::getRight() {
    return mvlist[ms3 - 1];
}
 
int Dice::getFront() {
    return mvlist[ms2 - 1];
}
 
bool Dice::operator==(const Dice& rhs) const {
    if (mvlist[ms1 - 1] == rhs.mvlist[rhs.ms1 - 1] &&
        mvlist[ms2 - 1] == rhs.mvlist[rhs.ms2 - 1] &&
        mvlist[ms3 - 1] == rhs.mvlist[rhs.ms3 - 1] &&
        mvlist[ms4 - 1] == rhs.mvlist[rhs.ms4 - 1] &&
        mvlist[ms5 - 1] == rhs.mvlist[rhs.ms5 - 1] &&
        mvlist[ms6 - 1] == rhs.mvlist[rhs.ms6 - 1])
    {
        return true;
    }
    return false;
}
 
int main(int argc, const char *argv[]) {
    int s1, s2, s3, s4, s5, s6;
    std::cin >> s1 >> s2 >> s3 >> s4 >> s5 >> s6;
    Dice dice1(s1, s2, s3, s4, s5, s6);
    std::cin >> s1 >> s2 >> s3 >> s4 >> s5 >> s6;
    Dice dice2(s1, s2, s3, s4, s5, s6);
    bool ret = false;
    for (int i = 1; i <= 6; i++) {
        if (!dice1.rollToTop(i)) {
            continue;
        }
        for (int j = 1; j <= 6; j++) {
            if (!dice1.rollToFrontHorizontal(j)) {
                continue;
            }
            if (dice1 == dice2) {
                ret = true;
                break;
            }
        }
        if (ret) {
            break;
        }
    }
    if (ret) {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No" << std::endl;
    }
    return 0;
}

Measured memory_bytes: 3108