#include <bits/stdc++.h>
using namespace std;
vector<string> _split(const string& s, char c) {
  vector<string> v;
  stringstream ss(s);
  string x;
  while (getline(ss, x, c)) v.emplace_back(x);
  return v;
}
void _print(vector<string>::iterator) {}
template <typename T, typename... Args>
void _print(vector<string>::iterator it, T a, Args... args) {
  string name = it->substr((*it)[0] == ' ', it->length());
  if (isalpha(name[0]))
    cerr << name << " = " << a << " ";
  else
    cerr << name << " ";
  _print(++it, args...);
}
string r(string s) {
  string res;
  for (char c : s)
    if (c != 'X') res.push_back(c);
  return res;
}
string rev(string s) {
  reverse(s.begin(), s.end());
  return s;
}
int main() {
  string s1, s2;
  cin >> s1 >> s2;
  string a = s1 + rev(s2);
  cin >> s1 >> s2;
  string b = s1 + rev(s2);
  a = r(a);
  b = r(b) + r(b);
  bool can = false;
  for (int i = 0; i < 3; i++) can |= b.substr(i, 3) == a;
  printf("%s\n", (can ? "YES" : "NO"));
  return 0;
}
