#include <bits/stdc++.h>
using namespace std;
map<vector<vector<char> >, bool> used;
void dfs(vector<vector<char> > v) {
  if (used[v]) return;
  used[v] = true;
  for (int i = 0; i < 2; i++)
    for (int j = 0; j < 2; j++) {
      if (v[i][j] == 'X') {
        swap(v[i][j], v[(i + 1) % 2][j]);
        dfs(v);
        swap(v[i][j], v[(i + 1) % 2][j]);
        swap(v[i][j], v[i][(j + 1) % 2]);
        dfs(v);
        swap(v[i][j], v[i][(j + 1) % 2]);
      }
    }
}
int main() {
  vector<vector<char> > a(2), b(2);
  for (int i = 0; i < 2; i++) {
    a[i].resize(2);
    for (int j = 0; j < 2; j++) {
      cin >> a[i][j];
    }
  }
  for (int i = 0; i < 2; i++) {
    b[i].resize(2);
    for (int j = 0; j < 2; j++) cin >> b[i][j];
  }
  dfs(a);
  if (used[b])
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}
