#include <bits/stdc++.h>
using namespace std;
int main() {
  string a = "", b = "";
  string t;
  cin >> t;
  if (t[0] != 'X') a += t[0];
  if (t[1] != 'X') a += t[1];
  cin >> t;
  if (t[1] != 'X') a += t[1];
  if (t[0] != 'X') a += t[0];
  cin >> t;
  if (t[0] != 'X') b += t[0];
  if (t[1] != 'X') b += t[1];
  cin >> t;
  if (t[1] != 'X') b += t[1];
  if (t[0] != 'X') b += t[0];
  if ((a[0] == b[0] && a[1] == b[1] && a[2] == b[2]) ||
      (a[0] == b[1] && a[1] == b[2] && a[2] == b[0]) ||
      (a[0] == b[2] && a[1] == b[0] && a[2] == b[1]))
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
