#include <bits/stdc++.h>
using namespace std;
string s, t, k;
string str(string a) {
  if (a[1] == 'X')
    swap(a[1], a[3]);
  else if (a[2] == 'X')
    swap(a[2], a[3]);
  else if (a[0] == 'X')
    swap(a[0], a[2]), swap(a[2], a[3]);
  string b = a.substr(0, 3);
  return b;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> s >> k;
  s += k;
  s = str(s);
  cin >> t >> k;
  t += k;
  t = str(t);
  if (s == t) {
    cout << "YES\n";
    return 0;
  }
  swap(s[0], s[2]);
  swap(s[1], s[2]);
  if (s == t) {
    cout << "YES\n";
    return 0;
  }
  swap(s[0], s[2]);
  swap(s[1], s[2]);
  if (s == t) {
    cout << "YES\n";
    return 0;
  }
  cout << "NO\n";
  return 0;
}
