#include <bits/stdc++.h>
using namespace std;
int main() {
  char ch[2][2];
  char hc[2][2];
  map<int, char> mark, karm;
  std::vector<string> ad;
  for (int i = 0; i < 4; i++) {
    string s;
    cin >> s;
    ad.push_back(s);
  }
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < 2; j++) {
      ch[i][j] = ad[i][j];
    }
  }
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < 2; j++) {
      hc[i][j] = ad[i + 2][j];
    }
  }
  int y = 0;
  for (int i = 0; i < 2; i++) {
    if (i % 2 == 0) {
      for (int j = 0; j < 2; j++) {
        if (ch[i][j] != 'X') {
          mark[y] = ch[i][j];
          y++;
        }
      }
    } else {
      for (int j = 1; j >= 0; j--) {
        if (ch[i][j] != 'X') {
          mark[y] = ch[i][j];
          y++;
        }
      }
    }
  }
  y = 0;
  for (int i = 0; i < 2; i++) {
    if (i % 2 == 0) {
      for (int j = 0; j < 2; j++) {
        if (hc[i][j] != 'X') {
          karm[y] = hc[i][j];
          y++;
        }
      }
    } else {
      for (int j = 1; j >= 0; j--) {
        if (hc[i][j] != 'X') {
          karm[y] = hc[i][j];
          y++;
        }
      }
    }
  }
  char ch1 = mark[0];
  char ch2 = mark[1];
  for (int i = 0; i < 3; i++) {
    if (karm[i] == ch1) {
      if (i == 2) {
        if (karm[0] == ch2) {
          std::cout << "YES";
          return 0;
        } else {
          cout << "NO";
          return 0;
        }
      } else {
        if (karm[i + 1] == ch2) {
          std::cout << "YES";
          return 0;
        } else {
          cout << "NO";
          return 0;
        }
      }
    }
  }
}
