#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  string s[4];
  for (int i = 0; i < 4; ++i) cin >> s[i];
  string s1 = "", s2 = "";
  if (s[0][0] != 'X') s1 += s[0][0];
  if (s[0][1] != 'X') s1 += s[0][1];
  if (s[1][1] != 'X') s1 += s[1][1];
  if (s[1][0] != 'X') s1 += s[1][0];
  if (s[2][0] != 'X') s2 += s[2][0];
  if (s[2][1] != 'X') s2 += s[2][1];
  if (s[3][1] != 'X') s2 += s[3][1];
  if (s[3][0] != 'X') s2 += s[3][0];
  for (int i = 0; i < 3; ++i) {
    if (s1 == s2) {
      cout << "YES\n";
      return 0;
    }
    s1 += s1[0];
    s1.erase(s1.begin());
  }
  cout << "NO\n";
  return 0;
}
