#include <bits/stdc++.h>
using namespace std;
template <class T>
const T& max(const T& a, const T& b, const T& c) {
  return max(a, max(b, c));
}
template <class T>
const T& min(const T& a, const T& b, const T& c) {
  return min(a, min(b, c));
}
long long stoi(string& str) {
  istringstream second(str);
  long long i;
  second >> i;
  return i;
}
string itos(long long i) {
  stringstream second;
  second << i;
  return second.str();
}
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long lcm(long long a, long long b) { return (a * b) / gcd(a, b); }
long long poww(long long a, long long b) {
  if (b == 0) return 1;
  long long tmp = poww(a, b / 2);
  return (b & 1 ? a * tmp * tmp : tmp * tmp);
}
long long sumOfDigs(string s) {
  long long sum = 0;
  for (int i = 0; i < s.length(); i++) sum += s[i] - '0';
  return sum;
}
long long sumOfDigs(long long n) {
  return (n < 10 ? n : n % 10 + sumOfDigs(n / 10));
}
long long mod = poww(10, 9) + 7;
int months[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
using namespace std;
void t() { freopen("test.txt", "r", stdin); }
long long a[1000 * 100 + 1][20];
pair<long long, long long> aa[1000 * 100 + 1][20];
int main() {
  string t1, t2, s, tt, second;
  cin >> t1 >> t2;
  s += t1;
  reverse(t2.begin(), t2.end());
  s += t2;
  cin >> t1 >> t2;
  tt += t1;
  reverse(t2.begin(), t2.end());
  tt += t2;
  second = s;
  if (second == tt) {
    return cout << "YES" << endl, 0;
  }
  int pos = second.find('X');
  if (pos < 3) {
    swap(second[pos], second[pos + 1]);
    pos++;
  } else {
    swap(second[pos], second[0]);
    pos = 0;
  }
  if (second == tt) {
    return cout << "YES" << endl, 0;
  }
  while (second != s) {
    if (pos < 3) {
      swap(second[pos], second[pos + 1]);
      pos++;
    } else {
      swap(second[pos], second[0]);
      pos = 0;
    }
    if (second == tt) {
      return cout << "YES" << endl, 0;
    }
  }
  return cout << "NO" << endl, 0;
  return 0;
}
