#include <queue>
#include <vector>
#include <string>
#include <cassert>
#include <iostream>
#include <algorithm>
  
enum class Direction
{
    North = 0,
    East,
    South,
    West,
};
  
struct Number
{
    Number(int t, int f, int r, int l, int b, int btm)
        :top(t), front(f), right(r), left(l), back(b), bottom(btm) {}
  
    int top;
    int front;
    int right;
    int left;
    int back;
    int bottom;
};
  
bool operator==(const Number &lhs, const Number &rhs)
{
    return
        lhs.top == rhs.top &&
        lhs.front == rhs.front &&
        lhs.right == rhs.right &&
        lhs.left == rhs.left &&
        lhs.back == rhs.back &&
        lhs.bottom == rhs.bottom;
}
  
class Dice
{
    public:
        explicit Dice(const Number &number) :number_(number) {}
  
        Dice rotate_to(Direction direction) const
        {
            const Number number = [&](Direction direction) {
                switch(direction)
                {
                    default:
                        assert(!"Invalid Direction.");
                    case Direction::North:
                        return Number(number_.front, number_.bottom, number_.right, number_.left, number_.top, number_.back);
                    case Direction::East:
                        return Number(number_.left, number_.front, number_.top, number_.bottom, number_.back, number_.right);
                    case Direction::South:
                        return Number(number_.back, number_.top, number_.right, number_.left, number_.bottom, number_.front);
                    case Direction::West:
                        return Number(number_.right, number_.front, number_.bottom, number_.top, number_.back, number_.left);
                }
            }(direction);
            return Dice(number);
        }
  
        Number number() const { return number_; }
  
    private:
        Number number_;
};
  
bool operator==(const Dice &lhs, const Dice &rhs)
{
    return lhs.number() == rhs.number();
}
  
Dice make_dice()
{
    int top, front, right, left, back, bottom;
    std::cin >> top >> front >> right >> left >> back >> bottom;
    Number number(top, front, right, left, back, bottom);
    Dice dice(number);
    return dice;
}
  
bool exist(const Dice &dice, const std::vector<Dice> &memo)
{
    return std::find(memo.begin(), memo.end(), dice) != memo.end();
}
  
bool is_same(const Dice &target, std::queue<Dice> &dices, std::vector<Dice> &memo)
{
    if(dices.empty())
    {
        return false;
    }
    const std::vector<Direction> directions = { Direction::North, Direction::East, Direction::South, Direction::West, };
    for(const auto &direction : directions)
    {
        const auto dice = dices.front().rotate_to(direction);
        if(dice == target)
        {
            return true;
        }
        if(exist(dice, memo))
        {
            continue;
        }
        dices.push(dice);
        memo.push_back(dice);
    }
    dices.pop();
    return is_same(target, dices, memo);
}
  
std::string solve()
{
    const auto dice1 = make_dice();
    const auto dice2 = make_dice();
    std::queue<Dice> dices; dices.push(dice2);
    std::vector<Dice> memo = { dice2 };
    return is_same(dice1, dices, memo) ? "Yes" : "No";
}
  
int main()
{
    std::cout << solve() << std::endl;
    return 0;
}

Measured memory_bytes: 3212