#include <bits/stdc++.h>
using namespace std;
namespace FAST_IO {
template <typename T>
void read(T &a) {
  a = 0;
  int f = 1;
  char c = getchar();
  while (!isdigit(c)) {
    if (c == '-') {
      f = -1;
    }
    c = getchar();
  }
  while (isdigit(c)) {
    a = a * 10 + c - '0';
    c = getchar();
  }
  a = a * f;
}
template <typename T>
void write(T a) {
  if (a < 0) {
    a = -a;
    putchar('-');
  }
  if (a > 9) {
    write(a / 10);
  }
  putchar(a % 10 + '0');
}
template <typename T>
void writeln(T a) {
  write(a);
  puts("");
}
}  // namespace FAST_IO
string from, to;
map<string, int> vis;
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};
bool check(int x, int y) {
  if (x < 0 || y < 0 || x > 1 || y > 1) {
    return false;
  }
  return true;
}
void bfs() {
  queue<string> q;
  q.push(from);
  vis[from] = 1;
  while (q.size()) {
    string tmp = q.front();
    q.pop();
    int now[2][2];
    now[0][0] = tmp[0];
    now[0][1] = tmp[1];
    now[1][0] = tmp[2];
    now[1][1] = tmp[3];
    for (int i = 0; i < 2; i++) {
      for (int j = 0; j < 2; j++) {
        if (now[i][j] == 'X') {
          for (int ii = 0; ii < 4; ii++) {
            int newx = i + dx[ii];
            int newy = j + dy[ii];
            if (check(newx, newy)) {
              swap(now[i][j], now[newx][newy]);
              string tmpp;
              stringstream tmppp;
              for (int iii = 0; iii < 2; iii++) {
                for (int jjj = 0; jjj < 2; jjj++) {
                  tmppp << (char)now[iii][jjj];
                }
              }
              tmppp >> tmpp;
              if (!vis[tmpp]) {
                q.push(tmpp);
                vis[tmpp] = true;
              }
              swap(now[i][j], now[newx][newy]);
            }
          }
        }
      }
    }
  }
}
int main() {
  for (int i = 0; i < 2; i++) {
    string s;
    cin >> s;
    from += s;
  }
  for (int i = 0; i < 2; i++) {
    string s;
    cin >> s;
    to += s;
  }
  bfs();
  if (vis[to]) {
    cout << "YES";
  } else {
    cout << "NO";
  }
}
