#include <bits/stdc++.h>
using namespace std;
int main() {
  map<string, int> parent;
  ios::sync_with_stdio(false);
  string top, down;
  string start, end;
  cin >> top >> down;
  start = top + down;
  cin >> top >> down;
  end = top + down;
  queue<string> q;
  q.push(start);
  bool can = false;
  parent[start] = 1;
  string to;
  while (!q.empty()) {
    string here = q.front();
    q.pop();
    int index = 0;
    for (int i = 0; i < here.size(); i++) {
      if (here[i] == 'X') index = i;
    }
    if (index == 0 || index == 3) {
      to = here;
      swap(to[index], to[1]);
      if (parent[to] == 0) {
        q.push(to);
        parent[to] = parent[here] + 1;
      }
      to = here;
      swap(to[index], to[2]);
      if (parent[to] == 0) {
        q.push(to);
        parent[to] = parent[here] + 1;
      }
    } else if (index == 1 || index == 2) {
      to = here;
      swap(to[index], to[3]);
      if (parent[to] == 0) {
        q.push(to);
        parent[to] = parent[here] + 1;
      }
      to = here;
      swap(to[index], to[0]);
      if (parent[to] == 0) {
        q.push(to);
        parent[to] = parent[here] + 1;
      }
    }
  }
  if (parent[end])
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
