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