#include <bits/stdc++.h>
using namespace std;
void init(int arr[], int size) {
  for (int i = 0; i < size; ++i) {
    arr[i] = 0;
  }
}
int main() {
  string s1, s2, s3, s4;
  cin >> s1 >> s2 >> s3 >> s4;
  string temp1 = s1;
  string temp2 = s2;
  string temp3 = s3;
  string temp4 = s4;
  reverse(s2.begin(), s2.end());
  reverse(s4.begin(), s4.end());
  s1 += s2;
  s3 += s4;
  s1.erase(s1.find('X'), 1);
  s3.erase(s3.find('X'), 1);
  s1 += s1;
  reverse(temp1.begin(), temp1.end());
  reverse(temp3.begin(), temp3.end());
  temp1 += temp2;
  temp3 += temp4;
  temp1.erase(temp1.find('X'), 1);
  temp3.erase(temp3.find('X'), 1);
  temp1 += temp1;
  if ((s1.find(s3) != string::npos) || (temp1.find(temp3) != string::npos)) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}
