#include <bits/stdc++.h>
using namespace std;
string s1, s2;
int main() {
  string a, b, c, d;
  cin >> a >> b >> c >> d;
  for (int i = 0; i < 2; i++)
    if (a[i] != 'X') s1 += a[i];
  for (int i = 1; i >= 0; i--)
    if (b[i] != 'X') s1 += b[i];
  for (int i = 0; i < 2; i++)
    if (c[i] != 'X') s2 += c[i];
  for (int i = 1; i >= 0; i--)
    if (d[i] != 'X') s2 += d[i];
  s1 += s1;
  if (s1.find(s2) != string::npos)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}
