#include <bits/stdc++.h>
using namespace std;
int main() {
  string temp;
  cin >> temp;
  string a[4];
  a[0] = temp[0];
  a[1] = temp[1];
  cin >> temp;
  a[3] = temp[0];
  a[2] = temp[1];
  cin >> temp;
  string b[4];
  b[0] = temp[0];
  b[1] = temp[1];
  cin >> temp;
  b[3] = temp[0];
  b[2] = temp[1];
  string A = "";
  string B = "";
  for (int i = 0; i < 4; i++) {
    if (a[i] != "X") {
      A += a[i];
    }
    if (b[i] != "X") {
      B += b[i];
    }
  }
  A = A + A;
  string ans = "NO";
  for (int i = 0; i < 3; i++) {
    if (A.substr(i, 3) == B) {
      ans = "YES";
    }
  }
  cout << ans;
  return 0;
}
