#include <bits/stdc++.h>
using namespace std;
string s[2], t[2];
int x[4] = {-1, 1, 0, 0};
int y[4] = {0, 0, 1, -1};
void solve() {
  int n = 2, m = 2;
  for (int i = 0; i < n; i++) cin >> s[i];
  for (int j = 0; j < 2; j++) cin >> t[j];
  queue<pair<string, string> > w;
  w.push(make_pair(s[0], s[1]));
  for (int iter = 0; iter <= 1000; iter++) {
    auto tmp = w.front();
    s[0] = tmp.first;
    s[1] = tmp.second;
    for (int i = 0; i < 2; i++)
      for (int j = 0; j < 2; j++) {
        if (s[i][j] == 'X') {
          for (int k = 0; k < 4; k++) {
            string q[2];
            q[0] = s[0];
            q[1] = s[1];
            int xx = (2 + i + x[k]) % 2;
            int yy = (2 + j + y[k]) % 2;
            swap(q[i][j], q[xx][yy]);
            if (q[0] == t[0] && q[1] == t[1]) {
              cout << "YES";
              return;
            }
            w.push(make_pair(q[0], q[1]));
          }
        }
      }
    w.pop();
  }
  cout << "NO";
  return;
}
int main() {
  solve();
  return 0;
}
