#include <bits/stdc++.h>
using namespace std;
void Erase(string& str) {
  if (str.find('X') != string::npos) str.erase(str.find('X'), 1);
}
int main() {
  string a, b, c, d;
  cin >> a >> b >> c >> d;
  Erase(a), Erase(b), Erase(c), Erase(d);
  reverse(b.begin(), b.end());
  reverse(d.begin(), d.end());
  a += b, a += a;
  c += d;
  a.find(c) == string::npos ? puts("NO") : puts("YES");
  return 0;
}
