#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline T MAX(T a, T b) {
  return a > b ? a : b;
}
template <typename T>
inline T MIN(T a, T b) {
  return a > b ? b : a;
}
template <typename T>
inline void SWAP(T &a, T &b) {
  T tp = a;
  a = b;
  b = tp;
}
template <typename T>
inline T GCD(T a, T b) {
  return b > 0 ? GCD(b, a % b) : a;
}
template <typename T>
inline void ADD_TO_VEC_int(T &n, vector<T> &vec) {
  vec.clear();
  cin >> n;
  for (int i = 0; i < n; i++) {
    T x;
    cin >> x, vec.push_back(x);
  }
}
template <typename T>
inline pair<T, T> MaxInVector_ll(vector<T> vec) {
  T MaxVal = -1e18, MaxId = 0;
  for (int i = 0; i < (int)vec.size(); i++)
    if (MaxVal < vec[i]) MaxVal = vec[i], MaxId = i;
  return {MaxVal, MaxId};
}
template <typename T>
inline pair<T, T> MinInVector_ll(vector<T> vec) {
  T MinVal = 1e18, MinId = 0;
  for (int i = 0; i < (int)vec.size(); i++)
    if (MinVal > vec[i]) MinVal = vec[i], MinId = i;
  return {MinVal, MinId};
}
template <typename T>
inline pair<T, T> MaxInVector_int(vector<T> vec) {
  T MaxVal = -0x7FFFFFFF, MaxId = 0;
  for (int i = 0; i < (int)vec.size(); i++)
    if (MaxVal < vec[i]) MaxVal = vec[i], MaxId = i;
  return {MaxVal, MaxId};
}
template <typename T>
inline pair<T, T> MinInVector_int(vector<T> vec) {
  T MinVal = 0x7FFFFFFF, MinId = 0;
  for (int i = 0; i < (int)vec.size(); i++)
    if (MinVal > vec[i]) MinVal = vec[i], MinId = i;
  return {MinVal, MinId};
}
template <typename T>
inline pair<map<T, T>, vector<T> > DIV(T n) {
  T nn = n;
  map<T, T> cnt;
  vector<T> div;
  for (long long i = 2; i * i <= nn; i++) {
    while (n % i == 0) {
      if (!cnt[i]) div.push_back(i);
      cnt[i]++;
      n /= i;
    }
  }
  if (n != 1) {
    if (!cnt[n]) div.push_back(n);
    cnt[n]++;
    n /= n;
  }
  return {cnt, div};
}
vector<vector<char> > tgt;
vector<vector<char> > stt;
int flag = 0;
inline void DFS(vector<vector<char> > cur, int steps) {
  if (flag || steps >= 10) return;
  if (cur == tgt) {
    cout << "YES" << endl;
    flag = true;
    return;
  }
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < 2; j++) {
      if (cur[i][j] == 'X') {
        if (i == 0)
          SWAP(cur[i][j], cur[i + 1][j]), DFS(cur, steps + 1),
              SWAP(cur[i][j], cur[i + 1][j]);
        else if (i == 1)
          SWAP(cur[i][j], cur[i - 1][j]), DFS(cur, steps + 1),
              SWAP(cur[i][j], cur[i - 1][j]);
        if (j == 0)
          SWAP(cur[i][j], cur[i][j + 1]), DFS(cur, steps + 1),
              SWAP(cur[i][j], cur[i][j + 1]);
        else if (j == 1)
          SWAP(cur[i][j], cur[i][j - 1]), DFS(cur, steps + 1),
              SWAP(cur[i][j], cur[i][j - 1]);
      }
    }
  }
}
int main() {
  for (int i = 0; i < 2; i++) {
    vector<char> vec;
    for (int j = 0; j < 2; j++) {
      char x;
      cin >> x;
      vec.push_back(x);
    }
    tgt.push_back(vec);
  }
  for (int i = 0; i < 2; i++) {
    vector<char> vec;
    for (int j = 0; j < 2; j++) {
      char x;
      cin >> x;
      vec.push_back(x);
    }
    stt.push_back(vec);
  }
  DFS(stt, 0);
  if (!flag) cout << "NO" << endl;
  exit(0);
}
