#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  std::vector<char> a1, b1;
  for (int i = 0; i < 2; i++) {
    cin >> s;
    if (i % 2 == 0) {
      if (s[0] != 'X') a1.push_back(s[0]);
      if (s[1] != 'X') a1.push_back(s[1]);
    } else {
      if (s[1] != 'X') a1.push_back(s[1]);
      if (s[0] != 'X') a1.push_back(s[0]);
    }
  }
  for (int i = 0; i < 2; i++) {
    cin >> s;
    if (i % 2 == 0) {
      if (s[0] != 'X') b1.push_back(s[0]);
      if (s[1] != 'X') b1.push_back(s[1]);
    } else {
      if (s[1] != 'X') b1.push_back(s[1]);
      if (s[0] != 'X') b1.push_back(s[0]);
    }
  }
  int count = 0;
  for (int i = 0; i < 3; i++)
    if (a1[i] == b1[i]) count++;
  if (count == 3) {
    cout << "YES";
    return 0;
  }
  count = 0;
  for (int i = 0; i < 3; i++)
    if (a1[i] == b1[(i + 1) % 3]) count++;
  if (count == 3) {
    cout << "YES";
    return 0;
  }
  for (int i = 0; i < 3; i++)
    if (a1[i] == b1[(i + 2) % 3]) count++;
  if (count == 3) {
    cout << "YES";
    return 0;
  }
  cout << "NO";
}
