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