#include <bits/stdc++.h>
using namespace std;
const int N = 205;
const int MAX = 2000000000;
const double EPS = 0.000001;
string a, b, c;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> a >> b;
  a = a + b[1] + b[0];
  cin >> b >> c;
  b = b + c[1] + c[0];
  for (int i = 0; i < 4; i++) {
    if (a[i] == 'X') a.erase(i, 1);
    if (b[i] == 'X') b.erase(i, 1);
  }
  bool f;
  for (int i = 0; i < 3 && !f; i++) {
    f = true;
    for (int j = 0; j < 3; j++) {
      if (a[j] != b[(i + j) % 3]) f = false;
    }
  }
  if (f)
    cout << "YES";
  else
    cout << "NO";
}
