#include <bits/stdc++.h>
using namespace std;
int fn(string s, int n) {
  int a;
  int k = int(s[0]) - int(s[1]);
  if (s[0] != 'X' && s[1] != 'X') {
    switch (k) {
      case -1:
        a = 1;
        break;
      case 1:
        a = -1;
        break;
      case -2:
        a = -1;
        break;
      case 2:
        a = 1;
        break;
    }
    return a * n;
  } else
    return 0;
}
int main() {
  string a, b, c, d;
  cin >> a >> b >> c >> d;
  int c1 = fn(a, 1) + fn(b, -1);
  int c2 = fn(c, 1) + fn(d, -1);
  if (c1 == c2)
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
