#include <bits/stdc++.h>
using namespace std;
bool comparator(pair<long long, long long> p1, pair<long long, long long> p2) {
  if (p1.first == p2.first) return p1.second < p2.second;
  return p1.first < p2.first;
}
void makeCycle(string &s, vector<vector<char>> &v) {
  int i, j;
  i = 0, j = 0;
  if (v[i][j] != 'X') s.push_back(v[i][j]);
  i = 0, j = 1;
  if (v[i][j] != 'X') s.push_back(v[i][j]);
  i = 1, j = 1;
  if (v[i][j] != 'X') s.push_back(v[i][j]);
  i = 1, j = 0;
  if (v[i][j] != 'X') s.push_back(v[i][j]);
}
int main() {
  int t;
  t = 1;
  while (t--) {
    vector<vector<char>> v1(2, vector<char>(2));
    vector<vector<char>> v2(2, vector<char>(2));
    for (int i = 0; i < 2; i++) {
      for (int j = 0; j < 2; j++) {
        cin >> v1[i][j];
      }
    }
    for (int i = 0; i < 2; i++) {
      for (int j = 0; j < 2; j++) {
        cin >> v2[i][j];
      }
    }
    if (v1[0][0] == 'X') {
      swap(v1[0][0], v1[1][0]);
    }
    while (v2[0][0] != v1[0][0]) {
      vector<vector<char>> temp(2, vector<char>(2));
      temp[0][0] = v2[1][0];
      temp[0][1] = v2[0][0];
      temp[1][1] = v2[0][1];
      temp[1][0] = v2[1][1];
      v2 = temp;
    }
    string s1, s2;
    makeCycle(s1, v1);
    makeCycle(s2, v2);
    if (s1 == s2) {
      cout << "YES";
    } else
      cout << "NO";
    cout << endl;
  }
}
