#include <bits/stdc++.h>
using namespace std;
int main() {
  string s[4];
  for (int i = 0; i < 4; i++) cin >> s[i];
  string s1, s2;
  for (int i = 0; i < 2; i++)
    if (s[0][i] != 'X') s1 += s[0][i];
  for (int i = 0; i < 2; i++)
    if (s[1][1 - i] != 'X') s1 += s[1][1 - i];
  for (int i = 0; i < 2; i++)
    if (s[2][i] != 'X') s2 += s[2][i];
  for (int i = 0; i < 2; i++)
    if (s[3][1 - i] != 'X') s2 += s[3][1 - i];
  if (s1 == s2 || s1 == s2.substr(1, 2) + s2[0] ||
      s1 == s2.substr(2, 1) + s2[0] + s2[1])
    cout << "YES";
  else
    cout << "NO";
}
