#include <bits/stdc++.h>
using namespace std;
string A[2], B[2];
int arr[100][2] = {{0, 0}, {0, 1}, {1, 1}, {1, 0}};
void shift(string& s) {
  char C = s[0];
  s = s.substr(1, 2) + C;
}
int main() {
  cin >> A[0] >> A[1] >> B[0] >> B[1];
  string a = "";
  string b = "";
  for (int i = 0; i < 4; i++) {
    if (A[arr[i][0]][arr[i][1]] != 'X') a += A[arr[i][0]][arr[i][1]];
    if (B[arr[i][0]][arr[i][1]] != 'X') b += B[arr[i][0]][arr[i][1]];
  }
  for (int i = 0; i < 10; i++) {
    if (a == b) {
      cout << "YES" << '\n';
      return 0;
    }
    shift(a);
  }
  cout << "NO" << '\n';
  return 0;
}
