#include <bits/stdc++.h>
using namespace std;
int main() {
  int i;
  string s1, s2, s3, s4;
  char vr1, vr2, vr3, vr4;
  cin >> s1 >> s2;
  cin >> s3 >> s4;
  for (i = 0; i < 12; i++) {
    vr1 = s1[0];
    vr2 = s1[1];
    vr4 = s2[0];
    vr3 = s2[1];
    if (s1[0] == 'X') {
      s1[0] = vr2;
      s1[1] = 'X';
    } else if (s1[1] == 'X') {
      s1[1] = vr3;
      s2[1] = 'X';
    } else if (s2[0] == 'X') {
      s2[0] = vr1;
      s1[0] = 'X';
    } else if (s2[1] == 'X') {
      s2[1] = vr4;
      s2[0] = 'X';
    }
    if (s1[0] == s3[0] && s1[1] == s3[1] && s2[0] == s4[0] && s2[1] == s4[1]) {
      cout << "YES";
      return 0;
    }
  }
  cout << "NO";
  return 0;
}
