#include <bits/stdc++.h>
std::string read() {
  std::string temp;
  std::cin >> temp;
  if (temp[0] == 'X') {
    return temp.substr(1);
  } else if (temp[1] == 'X') {
    return temp.substr(0, 1);
  } else {
    return temp;
  }
}
int main() {
  std::string s1, s2;
  std::string t;
  s1 = read();
  t = read();
  reverse(t.begin(), t.end());
  s1 += t;
  s2 = read();
  t = read();
  reverse(t.begin(), t.end());
  s2 += t;
  t = s1.substr(0, 2);
  if (s2.find(t) != -1) {
    std::cout << "YES";
    return 0;
  }
  t = s1.substr(1, 2);
  if (s2.find(t) != -1) {
    std::cout << "YES";
    return 0;
  }
  t = s1.substr(2, 1) + s1.substr(0, 1);
  if (s2.find(t) != -1) {
    std::cout << "YES";
    return 0;
  }
  std::cout << "NO";
  return 0;
}
