#include <iostream>
#include <memory>
#include <array>
#include <list>
#include <vector>
#include <algorithm>

using namespace std;

using spot_array_t = std::array<int, 6>;

class Dice {

public:
   Dice(spot_array_t set_spot) :
      spot_list{},
      top_id{ 0 },
      front_id{ 1 },
      right_id{ 2 }
   {
      spot_list.swap(set_spot);
      FixedSpin();
   }

   enum class direction_t {
      north,
      south,
      east,
      west
   };

   void Spin(direction_t direction) {
      switch (direction) {
      case direction_t::north: {
         int tmp = top_id;
         top_id = front_id;
         front_id = 5 - tmp;
         break;
      }
      case direction_t::south: {
         int tmp = front_id;
         front_id = top_id;
         top_id = 5 - tmp;
         break;
      }
      case direction_t::east: {
         int tmp = right_id;
         right_id = top_id;
         top_id = 5 - tmp;
         break;
      }
      case direction_t::west: {
         int tmp = top_id;
         top_id = right_id;
         right_id = 5 - tmp;
         break;
      }
      }
   }

   int Print() const {
      return spot_list.at(top_id);
   }

   bool operator==(const Dice& other) const {
      int bottom_id = 5 - top_id;
      int back_id = 5 - front_id;
      int left_id = 5 - right_id;
      const auto& my_id_list = Get_id_list();
      const auto& other_id_list = other.Get_id_list();
      for (int i = 0; i < my_id_list.size(); ++i) {
         const int my_spot = spot_list.at(my_id_list.at(i));
         const int other_spot = other.spot_list.at(other_id_list.at(i));
         if (my_spot != other_spot) { return false; }
      }
      return true;
   }

   bool operator!=(const Dice& other) const {
      return !(*this == other);
   }

   bool operator<(const Dice& other) const {
      const long my_dice_id = Get_dice_id();
      const long other_dice_id = other.Get_dice_id();
      return my_dice_id < other_dice_id;
   }

private:
   void FixedSpin() {
      int max_count_spot = -1;
      int spot_max_count = 7;
      for (const auto spot : spot_list) {
         int spot_count = std::count(spot_list.cbegin(), spot_list.cend(), spot);
         if (spot_count > spot_max_count) { continue; }
         if (spot_count < spot_max_count) {
            spot_max_count = spot_count;
            max_count_spot = spot;
            continue;
         }
         if (spot <= max_count_spot) { continue; }
         max_count_spot = spot;
      }
      std::list<int> max_count_spot_id_list;
      const int list_size = spot_list.size();
      for (int id = 0; id < list_size; ++id) {
         if (spot_list.at(id) == max_count_spot) {
            max_count_spot_id_list.emplace_back(id);
         }
      }
      for (const auto id : max_count_spot_id_list) {
         Dice temp_dice{ *this };
         temp_dice.Spin_for_top(id);
         for (int i = 0; i < 4; ++i) {
            temp_dice.Spin_horizontal(temp_dice.right_id);
            if (*this < temp_dice) { continue; }
            *this = temp_dice;
         }
      }
   }

   long Get_dice_id(int digit = 0) const {
      const auto& id_list = Get_id_list();
      const int id = id_list.at(digit);
      const int spot = spot_list.at(id);
      if (digit == id_list.size() - 1) {
         return spot;
      }
      return Get_dice_id(digit + 1) * 10 + spot;
   };

   std::vector<int> Get_id_list() const {
      int bottom_id = 5 - top_id;
      int back_id = 5 - front_id;
      int left_id = 5 - right_id;
      return { top_id, front_id, right_id, left_id, back_id, bottom_id };
   }

   bool Spin_for_top(int set_top_id) {
      int bottom_id = 5 - top_id;
      int back_id = 5 - front_id;
      int left_id = 5 - right_id;

      if (top_id == set_top_id) {
      } else if (front_id == set_top_id) {
         Spin(direction_t::north);
      } else if (right_id == set_top_id) {
         Spin(direction_t::west);
      } else if (bottom_id == set_top_id) {
         Spin(direction_t::north);
         Spin(direction_t::north);
      } else if (back_id == set_top_id) {
         Spin(direction_t::south);
      } else if (left_id == set_top_id) {
         Spin(direction_t::east);
      } else {
         return false;
      }
      return true;
   }

   void Spin_horizontal(int set_front_id) {
      Spin(direction_t::north);
      while (top_id != set_front_id) {
         Spin(direction_t::west);
      }
      Spin(direction_t::south);
   }

   static constexpr int SPOT_MAX = 100;

   spot_array_t spot_list;

   int top_id;
   int front_id;
   int right_id;

};

int main() {

   int dice_number = 2;
   std::list<std::unique_ptr<Dice>> dice_list;
   while (dice_number--) {
      spot_array_t spot_list;
      for (auto&& spot : spot_list) {
         cin >> spot;
      }
      dice_list.emplace_back(new Dice(std::move(spot_list)));
   }

   bool match_all = true;
   const auto itrBegin = dice_list.begin();
   const auto itrEnd = dice_list.end();
   auto itr = itrBegin;
   ++itr;
   for (; itr != itrEnd; ++itr) {
      if (**itrBegin != **itr) {
         match_all = false;
         break;
      }
   }

   cout << (match_all ? "Yes" : "No") << endl;

   return 0;

}

Measured memory_bytes: 3144