import java.io.*;
import java.math.*;
import java.util.*;
public class Main1 {
	public static String rev(String r)
	{
		return new StringBuilder(r).reverse().toString();
	}
public static void main(String[] args) throws IOException {
	File file = new File("in");
	BufferedReader in = new BufferedReader(file.exists() ? new FileReader(file) : new InputStreamReader(System.in));
	StringBuilder out = new StringBuilder("");
	String line, lines[];
	String l1, l2, a1, a2;
	l1 = in.readLine();
	l2 = in.readLine();
	a1 = in.readLine();
	a2 = in.readLine();

	String l = l1.replace("X", "")+ rev(l2).replace("X", "");
	String a = a1.replace("X", "")+ rev(a2).replace("X", "");
	boolean flag = false;
	for( int i = 0; i < 3; i++ )
	{
		if ( l.charAt(i) == a.charAt(0) && l.charAt((i+1)%3) == a.charAt(1) && l.charAt((i+2)%3) == a.charAt(2))
		{
			flag = true;
		}
	}
	if ( flag) System.out.println("YES");
	else System.out.println("NO");
}
}

import java.io.*;
import java.util.*;

public class Prob645A{
   public static void main(String[] args) throws Exception{
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      String[] l1 = br.readLine().split("");
      String[] l2 = br.readLine().split("");
      String[] l3 = br.readLine().split("");
      String[] l4 = br.readLine().split("");
      String s1 = "";
      if(!l1[0].equals("X"))
         s1 += l1[0];
      if(!l1[1].equals("X"))
         s1 += l1[1];
      if(!l2[1].equals("X"))
         s1 += l2[1];
      if(!l2[0].equals("X"))
         s1 += l2[0];
      String s2 = "";
      if(!l3[0].equals("X"))
         s2 += l3[0];
      if(!l3[1].equals("X"))
         s2 += l3[1];
      if(!l4[1].equals("X"))
         s2 += l4[1];
      if(!l4[0].equals("X"))
         s2 += l4[0];
      if((s1 + s1).contains(s2)) System.out.println("YES");
      else System.out.println("NO");
   }
}

import static java.lang.Double.parseDouble;
import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
import static java.lang.System.exit;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class A {

	static BufferedReader in;
	static PrintWriter out;
	static StringTokenizer tok;

	static boolean get() throws Exception {
		char chars[] = new char[3];
		int cnt = 0;
		for (int i = 0; i < 2; i++) {
			String l = next();
			for (int j = 0; j < 2; j++) {
				char c = l.charAt(i == 0 ? j : 1 - j);
				if (c >= 'A' && c <= 'C') {
					chars[cnt++] = c;
				}
			}
		}
		if (cnt != 3) {
			throw new AssertionError();
		}
		for (int it = 0; it < 3; it++) {
			if (chars[0] == 'A' && chars[1] == 'B' && chars[2] == 'C') {
				return false;
			}
			if (chars[0] == 'A' && chars[1] == 'C' && chars[2] == 'B') {
				return true;
			}
			char c = chars[0];
			chars[0] = chars[1];
			chars[1] = chars[2];
			chars[2] = c;
		}
		throw new AssertionError();
	}

	static void solve() throws Exception {
		out.print(get() == get() ? "YES" : "NO");
	}

	static int nextInt() throws IOException {
		return parseInt(next());
	}

	static long nextLong() throws IOException {
		return parseLong(next());
	}

	static double nextDouble() throws IOException {
		return parseDouble(next());
	}

	static String next() throws IOException {
		while (tok == null || !tok.hasMoreTokens()) {
			tok = new StringTokenizer(in.readLine());
		}
		return tok.nextToken();
	}

	public static void main(String[] args) {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(new OutputStreamWriter(System.out));
			solve();
			in.close();
			out.close();
		} catch (Throwable e) {
			e.printStackTrace();
			exit(1);
		}
	}
}

import java.io.*;
import java.util.*;
public class Main
{

    public static void main(String[] args) throws IOException
    {

    	BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
      String line1 = f.readLine();
      String line2 = f.readLine();
      String line3 = f.readLine();
      String line4 = f.readLine();
      String input1 = (line1 + line2.charAt(1) + line2.charAt(0)).replace("X", "");
      String input2 = (line3 + line4.charAt(1) + line4.charAt(0)).replace("X", "");
      if((input2 + input2).contains(input1))
         System.out.println("YES");
      else
         System.out.println("NO");
   }
}

import java.io.*;
public class AmityAssessment {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader (new InputStreamReader(System.in));
		int x = -1;
		String s = br.readLine();
		String [] B1 = new String[2];
		B1[0] = s.charAt(0)+"";
		B1[1] = s.charAt(1)+"";
		if(B1[0].equals("X")){
			x=0;
		}else if(B1[1].equals("X")){
			x=1;
		}
		s = br.readLine();
		String [] B2 = new String[2];
		B2[0] = s.charAt(0)+"";
		B2[1] = s.charAt(1)+"";
		if(B2[0].equals("X")){
			x=2;
		}else if(B2[1].equals("X")){
			x=3;
		}
		s = br.readLine();
		String [] A1 = new String[2];
		A1[0] = s.charAt(0)+"";
		A1[1] = s.charAt(1)+"";
		s = br.readLine();
		String [] A2 = new String[2];
		A2[0] = s.charAt(0)+"";
		A2[1] = s.charAt(1)+"";
		int count =1;
		boolean flag = false;
		while(count <= 12){
			count++;
			if(x==0){
				B1[0] = B1[1];

				B1[1] = "X";
			}else if(x==1){
				B1[1] = B2[1];

				B2[1] = "X";
			}else if(x==2){

				B2[0] = B1[0];
				B1[0] = "X";
			}else if(x==3){
				B2[1] = B2[0];
				B2[0] = "X";
			}
			if(B1[0].equals(A1[0]) && B1[1].equals(A1[1]) && B2[0].equals(A2[0]) && B2[1].equals(A2[1])){
				flag = true;
				break;
			}
			if(B1[0].equals("X")){
				x=0;
			}else if(B1[1].equals("X")){
				x=1;
			}else if(B2[0].equals("X")){
				x=2;
			}else if(B2[1].equals("X")){
				x=3;
			}
		}
		if(flag){
			System.out.println("YES");
		}else{
			System.out.println("NO");
		}

	}

}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.ArrayList;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Alex
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }
    static class TaskA {
        void add(char c, ArrayList<Integer> al) {
            if(c == 'X') return;
            al.add(c - 'A');
        }

        ArrayList<Integer> pop(InputReader in) {
            ArrayList<Integer> res = new ArrayList<>();
            char[][] tab = new char[2][2];
            for(int i = 0; i < 2; i++)
                tab[i] = IOUtils.readCharArray(in, 2);
            add(tab[0][0], res);
            add(tab[0][1], res);
            add(tab[1][1], res);
            add(tab[1][0], res);
            return res;
        }

        public void solve(int testNumber, InputReader in, OutputWriter out) {
            ArrayList<Integer> first = pop(in), second = pop(in);
            int fi = 0, si = 0;
            while(first.get(fi) != 0) fi++;
            while(second.get(si) != 0) si++;
            for(int i = 0; i < 3; i++) {
                if(first.get((fi + i) % 3) != second.get((si + i) % 3)) {
                    out.printLine("NO");
                    return;
                }
            }
            out.printLine("YES");
        }

    }

    static class IOUtils {
        public static char[] readCharArray(InputReader in, int size) {
            char[] array = new char[size];
            for(int i = 0; i < size; i++)
                array[i] = in.readCharacter();
            return array;
        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void print(Object... objects) {
            for(int i = 0; i < objects.length; i++) {
                if(i != 0)
                    writer.print(' ');
                writer.print(objects[i]);
            }
        }

        public void printLine(Object... objects) {
            print(objects);
            writer.println();
        }

        public void close() {
            writer.close();
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if(numChars == -1)
                throw new InputMismatchException();
            if(curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch(IOException e) {
                    throw new InputMismatchException();
                }
                if(numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public boolean isSpaceChar(int c) {
            if(filter != null)
                return filter.isSpaceChar(c);
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public char readCharacter() {
            int c = read();
            while(isSpaceChar(c))
                c = read();
            return (char) c;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}

import java.io.*;
import java.util.*;

public class A {

    public void solve() {
        String a = in.nextToken() + new StringBuilder(in.nextToken()).reverse();
        String b = in.nextToken() + new StringBuilder(in.nextToken()).reverse();
        a = a.replace("X", "");
        b = b.replace("X", "");

        for (int i = 0; i < 3; i++) {
            String s = b.substring(i) + b.substring(0, i);
            if (a.equals(s)) {
                out.println("YES");
                return;
            }
        }
        out.println("NO");
    }

    public void run() {
        in = new FastScanner();
        out = new PrintWriter(System.out);
        solve();
        out.close();
    }

    FastScanner in;
    PrintWriter out;

    class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(String fileName) {
            try {
                br = new BufferedReader(new FileReader(fileName));
            } catch (FileNotFoundException e) {
            }
        }

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String nextToken() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(nextToken());
        }

        long nextLong() {
            return Long.parseLong(nextToken());
        }

        double nextDouble() {
            return Double.parseDouble(nextToken());
        }
    }

    public static void main(String[] args) {
        new A().run();
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Tester {
	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		ArrayList<Character> list1 = new ArrayList<Character>(3);
		ArrayList<Character> list2 = new ArrayList<Character>(3);
		String temp = br.readLine();
		int count=0;
		for (int i = 0; i < 2; i++) {
			if(temp.charAt(i)!='X')
			{
				list1.add(count, temp.charAt(i));
			   count++;
			}
		}
		temp = br.readLine();
		for (int i = 0; i < 2; i++) {
			if(temp.charAt(1-i)!='X'){
				list1.add(count, temp.charAt(1-i));
			     count++;
			}
		}
		count=0;
		temp = br.readLine();
		for (int i = 0; i < 2; i++) {
			if(temp.charAt(i)!='X'){
				list2.add(count, temp.charAt(i));
				count++;
			}
		}
		temp = br.readLine();
		for (int i = 0; i < 2; i++)
		if(temp.charAt(1-i)!='X'){
			list2.add(count, temp.charAt(1-i));
			count++;
		}
	//	for(int i=0;i<3;i++)
	//	{
	//		System.out.println(list1.get(i) +" " + list2.get(i));
	//	}
	     int flag=1;
	     //System.out.println(list2.get(1));
	    // System.out.println(list1.get(0));
	     for(int i=0;i<3;i++)
	      {
	    	 //System.out.println(list1.get(i-1));
	    		//System.out.println(list1.get(i));
	    		if(list2.get(i).equals(list1.get(0)))
	    	  {
	    		//System.out.println(i);

	    		  for(int j=0;j<3;j++)
	    		  {

	    			 i=i>2 ? 0 : i;
	    			  if(list2.get(i).equals(list1.get(j)))
	    			  i++;
	    			  else
	    			  {
	    				  flag=0;
	    				  break;
	    			  }
	    		  }
	    	  break;
	    	  }
	      }
	     if(flag==1)
	    	 System.out.println("YES");
	     else
	    	 System.out.println("NO");

	}
}

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class Main {

	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;

		InputReader in = new InputReader(inputStream);
		OutputWriter out = new OutputWriter(outputStream);

		TaskA solver = new TaskA();
		solver.solve(in, out);

		out.close();
	}

}

class TaskA {

	public void solve(InputReader in, OutputWriter out) {

		char[][] a = new char[2][2];
		a[0] = in.next().toCharArray();
		a[1] = in.next().toCharArray();
		f(a);

		char[][] b = new char[2][2];
		b[0] = in.next().toCharArray();
		b[1] = in.next().toCharArray();
		f(b);

		StringBuilder str1 = new StringBuilder("");
		str1.append(a[0][1]); str1.append(a[1][1]); str1.append(a[1][0]);
		StringBuilder str2 = new StringBuilder("");
		str2.append(b[0][1]); str2.append(b[1][1]); str2.append(b[1][0]);

		boolean flag = str1.toString().equalsIgnoreCase(str2.toString());
		for(int i = 0; i < 4; i++) {
			char c = str1.charAt(0);
			str1.deleteCharAt(0);
			str1.append(c);

			flag|=str1.toString().equalsIgnoreCase(str2.toString());
		}

		out.write(flag ? "YES" : "NO");
	}

	void f(char[][] c) {
		if(c[0][0] == 'X') return;
		if(c[0][1] == 'X') {
			char tmp = c[0][0];
			c[0][0] = c[0][1];
			c[0][1] = tmp;
			return;
		}
		if(c[1][0] == 'X') {
			char tmp = c[0][0];
			c[0][0] = c[1][0];
			c[1][0] = tmp;
			return;
		}
		if(c[1][1] == 'X') {
			char tmp  = c[1][0];
			c[1][0] = c[1][1];
			c[1][1] = tmp;
			f(c);
			return;
		}
	}

}

class InputReader {

	public InputReader(InputStream inputStream) {
		tokenizer = null;
		reader = new BufferedReader(new InputStreamReader(inputStream));
	}

	public String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}

		return tokenizer.nextToken();
	}

	public String nextLine() {
		try {
			return reader.readLine();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	StringTokenizer tokenizer;
	BufferedReader reader;
}

class OutputWriter {

	public OutputWriter(OutputStream outputStream) {
		out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(
				outputStream)));
	}

	public void write(Object... o) {
		for (Object x : o)
			out.print(x);
	}

	public void writeln(Object... o) {
		write(o);
		out.println();
	}

	public void close() {
		out.close();
	}

	PrintWriter out;
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Jaswant Singh[joney_000]
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        FastReader in;
        PrintWriter out;

        void set(FastReader in, PrintWriter out) {
            this.in = in;
            this.out = out;
        }

        public void solve(int testNumber, FastReader in, PrintWriter out) {
            set(in, out);
            String s = "";

            String temp = s();
            if (temp.charAt(0) != 'X') s += "" + temp.charAt(0);//
            if (temp.charAt(1) != 'X') s += "" + temp.charAt(1);//
            temp = s();
            if (temp.charAt(1) != 'X') s += "" + temp.charAt(1);//
            if (temp.charAt(0) != 'X') s += "" + temp.charAt(0);//

            String t = "";

            temp = s();
            if (temp.charAt(0) != 'X') t += "" + temp.charAt(0);//
            if (temp.charAt(1) != 'X') t += "" + temp.charAt(1);//
            temp = s();
            if (temp.charAt(1) != 'X') t += "" + temp.charAt(1);//
            if (temp.charAt(0) != 'X') t += "" + temp.charAt(0);//
            String ans = "NO";
            t = t + t;
            for (int i = 0; i <= 4; i++) {
                for (int j = 0; j <= 1; j++) {
                    if (s.charAt(j) != t.charAt(i + j)) break;
                    if (j == 1) ans = "YES";
                }
            }
            out.write("" + ans + "");

        }

        String s() {
            return in.nextLine();
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[4 * 1024];
        private int curChar;
        private int numChars;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        private String readLine0() {
            StringBuilder buf = new StringBuilder();
            int c = read();
            while (c != '\n' && c != -1) {
                if (c != '\r') {
                    buf.appendCodePoint(c);
                }
                c = read();
            }
            return buf.toString();
        }

        public String nextLine() {
            String s = readLine0();
            while (s.trim().length() == 0)
                s = readLine0();
            return s;
        }

    }
}

import java.util.Scanner;

public class A645 {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        StringBuilder first = new StringBuilder();
        char[] S = in.next().toCharArray();
        if (S[0] != 'X') first.append(S[0]);
        if (S[1] != 'X') first.append(S[1]);
        S = in.next().toCharArray();
        if (S[1] != 'X') first.append(S[1]);
        if (S[0] != 'X') first.append(S[0]);
        StringBuilder second = new StringBuilder();
        S = in.next().toCharArray();
        if (S[0] != 'X') second.append(S[0]);
        if (S[1] != 'X') second.append(S[1]);
        S = in.next().toCharArray();
        if (S[1] != 'X') second.append(S[1]);
        if (S[0] != 'X') second.append(S[0]);
        boolean match = false;
        for (int shift = 0; shift < 3; shift++) {
            boolean ok = true;
            for (int i=0; i<3; i++) {
                if (first.charAt(i) != second.charAt((i+shift)%3)) {
                    ok = false;
                }
            }
            if (ok) {
                match = true;
            }
        }
        System.out.println(match ? "YES" : "NO");
    }

}

//package croc2016.elim;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;

public class A {
	InputStream is;
	PrintWriter out;
	String INPUT = "";

	void solve()
	{
		char[][] map = nm(2,2);
		char[][] x = nm(2,2);
		int[][] ord = {
				{0, 0},
				{0, 1},
				{1, 1},
				{1, 0}
		};
		for(int u = 0;u < 100;u++){
			for(int i = 0;i < 4;i++){
				int[] o = ord[i];
				if(x[o[0]][o[1]] == 'X'){
					int[] p = ord[(i+1)&3];
					char c = x[p[0]][p[1]];
					x[p[0]][p[1]] = 'X';
					x[o[0]][o[1]] = c;
					break;
				}
			}
			if(same(map, x)){
				out.println("YES");
				return;
			}
		}
		out.println("NO");
	}

	boolean same(char[][] a, char[][] b)
	{
		for(int i = 0;i < 2;i++){
			for(int j = 0;j < 2;j++){
				if(a[i][j] != b[i][j])return false;
			}
		}
		return true;
	}

	void run() throws Exception
	{
		is = oj ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);

		long s = System.currentTimeMillis();
		solve();
		out.flush();
		tr(System.currentTimeMillis()-s+"ms");
	}

	public static void main(String[] args) throws Exception { new A().run(); }

	private byte[] inbuf = new byte[1024];
	private int lenbuf = 0, ptrbuf = 0;

	private int readByte()
	{
		if(lenbuf == -1)throw new InputMismatchException();
		if(ptrbuf >= lenbuf){
			ptrbuf = 0;
			try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); }
			if(lenbuf <= 0)return -1;
		}
		return inbuf[ptrbuf++];
	}

	private boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); }
	private int skip() { int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; }

	private double nd() { return Double.parseDouble(ns()); }
	private char nc() { return (char)skip(); }

	private String ns()
	{
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while(!(isSpaceChar(b))){ // when nextLine, (isSpaceChar(b) && b != ' ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	private char[] ns(int n)
	{
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while(p < n && !(isSpaceChar(b))){
			buf[p++] = (char)b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}

	private char[][] nm(int n, int m)
	{
		char[][] map = new char[n][];
		for(int i = 0;i < n;i++)map[i] = ns(m);
		return map;
	}

	private int[] na(int n)
	{
		int[] a = new int[n];
		for(int i = 0;i < n;i++)a[i] = ni();
		return a;
	}

	private int ni()
	{
		int num = 0, b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-'){
			minus = true;
			b = readByte();
		}

		while(true){
			if(b >= '0' && b <= '9'){
				num = num * 10 + (b - '0');
			}else{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private long nl()
	{
		long num = 0;
		int b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-'){
			minus = true;
			b = readByte();
		}

		while(true){
			if(b >= '0' && b <= '9'){
				num = num * 10 + (b - '0');
			}else{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private boolean oj = System.getProperty("ONLINE_JUDGE") != null;
	private void tr(Object... o) { if(!oj)System.out.println(Arrays.deepToString(o)); }
}

import java.util.*;

import java.io.*;

public class CCTrial {

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String s1=br.readLine();
		String s2=br.readLine();
		String s="";
		s+=Character.toString(s2.charAt(0)) + Character.toString(s1.charAt(0)) + Character.toString(s1.charAt(1)) + Character.toString(s2.charAt(1));
		s=s.replace("X", "");
		String p=Character.toString(s.charAt(2))+Character.toString(s.charAt(0))+Character.toString(s.charAt(1));
		String r=Character.toString(p.charAt(2))+Character.toString(p.charAt(0))+Character.toString(p.charAt(1));
		Set<String> hs=new HashSet<>();
		hs.add(s);hs.add(p);hs.add(r);
		String c=br.readLine();
		String d=br.readLine();
		String h=Character.toString(d.charAt(0)) + Character.toString(c.charAt(0)) + Character.toString(c.charAt(1)) + Character.toString(d.charAt(1));
		h=h.replace("X", "");
		if(hs.contains(h)) System.out.println("YES");
		else System.out.println("NO");
	}
	public static  String sub(String s,int i) {
		return s.substring(0,i);
	}
}

import java.io.*;
import java.util.*;

public class Main {

    private NotMyScanner in;
    private PrintWriter out;
//    private Timer timer = new Timer();

    private void solve() throws IOException {
        String a = in.next() + in.next();
        String b = in.next() + in.next();

        char[] A = new char[4], B = new char[4], sA = new char[3], sB = new char[3];
        A[0] = a.charAt(0);
        A[1] = a.charAt(1);
        A[2] = a.charAt(3);
        A[3] = a.charAt(2);

        B[0] = b.charAt(0);
        B[1] = b.charAt(1);
        B[2] = b.charAt(3);
        B[3] = b.charAt(2);

        for (int i = 0; i < 4; i++) {
            if (A[i] == 'X') {
                for (int j = 0; j < 3; j++) {
                    sA[j] = A[(i + 1 + j) % 4];
                }
            }
            if (B[i] == 'X') {
                for (int j = 0; j < 3; j++) {
                    sB[j] = B[(i + 1 + j) % 4];
                }
            }
        }

        for (int i = 0; i < 10; i++) {
            if (new String(sA).equals(new String(sB))) {
                out.println("YES");
                return;
            }
            char[] tmp = new char[3];
            for (int j = 0; j < 3; j++) {
                tmp[j] = sB[(j + 1) % 3];
            }
            sB = tmp;
        }

        out.println("NO");
    }

    private void run() throws IOException {
        in = new NotMyScanner();
        out = new PrintWriter(System.out, false);
        solve();
        out.close();
    }

    public static void main(String[] args) throws IOException {
        new Main().run();
    }
}

class NotMyScanner {

    private final BufferedReader br;
    private StringTokenizer st;
    private String last;

    public NotMyScanner() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    public NotMyScanner(String path) throws IOException {
        br = new BufferedReader(new FileReader(path));
    }

    public NotMyScanner(String path, String decoder) throws IOException {
        br = new BufferedReader(new InputStreamReader(new FileInputStream(path), decoder));
    }

    String next() throws IOException {
        while (st == null || !st.hasMoreElements())
            st = new StringTokenizer(br.readLine());
        last = null;
        return st.nextToken();
    }

    String nextLine() throws IOException {
        st = null;
        return (last == null) ? br.readLine() : last;
    }

    boolean hasNext() {
        if (st != null && st.hasMoreElements())
            return true;

        try {
            while (st == null || !st.hasMoreElements()) {
                last = br.readLine();
                st = new StringTokenizer(last);
            }
        } catch (Exception e) {
            return false;
        }

        return true;
    }

    String[] nextStrings(int n) throws IOException {
        String[] arr = new String[n];
        for (int i = 0; i < n; i++)
            arr[i] = next();
        return arr;
    }

    String[] nextLines(int n) throws IOException {
        String[] arr = new String[n];
        for (int i = 0; i < n; i++)
            arr[i] = nextLine();
        return arr;
    }

    int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    int[] nextInts(int n) throws IOException {
        int[] arr = new int[n];
        for (int i = 0; i < n; i++)
            arr[i] = nextInt();
        return arr;
    }

    Integer[] nextIntegers(int n) throws IOException {
        Integer[] arr = new Integer[n];
        for (int i = 0; i < n; i++)
            arr[i] = nextInt();
        return arr;
    }

    int[][] next2Ints(int n, int m) throws IOException {
        int[][] arr = new int[n][m];
        for (int i = 0; i < n; i++)
            for (int j = 0; j < m; j++)
                arr[i][j] = nextInt();
        return arr;
    }

    long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    long[] nextLongs(int n) throws IOException {
        long[] arr = new long[n];
        for (int i = 0; i < n; i++)
            arr[i] = nextLong();
        return arr;
    }

    long[][] next2Longs(int n, int m) throws IOException {
        long[][] arr = new long[n][m];
        for (int i = 0; i < n; i++)
            for (int j = 0; j < m; j++)
                arr[i][j] = nextLong();
        return arr;
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(next().replace(',', '.'));
    }

    double[] nextDoubles(int size) throws IOException {
        double[] arr = new double[size];
        for (int i = 0; i < size; i++)
            arr[i] = nextDouble();
        return arr;
    }

    boolean nextBool() throws IOException {
        String s = next();
        if (s.equalsIgnoreCase("true") || s.equals("1"))
            return true;

        if (s.equalsIgnoreCase("false") || s.equals("0"))
            return false;

        throw new IOException("Boolean expected, String found!");
    }
}

import java.util.*;
import java.io.*;

public class AmityAssessment {
	static BufferedReader br;
	static StringTokenizer tokenizer;

	public static void main(String[] args) throws Exception {
		br = new BufferedReader(new InputStreamReader(System.in));
		String s = "";
		String s1 = "";
		s += next();
		String t = next();
		s += t.charAt(1) + "" + t.charAt(0);
		s1 += next();
		t = next();
		s1 += t.charAt(1) + "" + t.charAt(0);
		s = removeX(s);
		s1 = removeX(s1);
		int start = 0;
		int start2 = 0;
//		System.out.println(s);
//		System.out.println(s1);
		for(int i = 0; i < 3; i++)
			if(s.charAt(i) == 'A')
				start = i;
		for(int i = 0; i < 3; i++)
			if(s1.charAt(i) == 'A')
				start2 = i;
		for(int i = 1;  i< 3; i++) {
			if(s.charAt((start + i) % 3) != s1.charAt((start2 + i) % 3)) {
				System.out.println("NO");
				return;
			}
		}
		System.out.println("YES");
	}
	public static String removeX(String s) {
		for(int i = 0; i < s.length(); i++)
			if(s.charAt(i) == 'X')
				return s.substring(0, i) + s.substring(i + 1);
		return null;
	}

	public static String next() throws IOException {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			String line = br.readLine();
			if (line == null)
				throw new IOException();
			tokenizer = new StringTokenizer(line);
		}
		return tokenizer.nextToken();
	}

	public static int nextInt() throws IOException {
		return Integer.parseInt(next());
	}
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, OutputWriter out) {
            String s1 = in.next() + in.next();
            String s2 = in.next() + in.next();

            char[] a = s1.toCharArray();
            char[] b = s2.toCharArray();
            swap(a, 2, 3);
            swap(b, 2, 3);

            int x0 = find(a, 'X');
            for (int i = 0; i < 4; i++) {
                if (checkCycle(a, b)) {
                    out.print("YES");
                    return;
                }
                int nextX0 = (x0 + 1) % 4;
                swap(a, x0, nextX0);
                x0 = nextX0;
            }
            out.print("NO");
        }

        private boolean checkCycle(char[] a, char[] b) {
            int x0 = find(a, 'X');
            int x1 = find(b, 'X');

            for (int i = 0; i < 4; i++) {
                if (a[x0] != b[x1]) {
                    return false;
                }
                x0 = (x0 + 1) % 4;
                x1 = (x1 + 1) % 4;
            }
            return true;
        }

        private void swap(char[] s, int i, int j) {
            char t = s[i];
            s[i] = s[j];
            s[j] = t;
        }

        private int find(char[] s, char c) {
            for (int i = 0; i < s.length; i++) {
                if (s[i] == c) {
                    return i;
                }
            }
            return -1;
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public String readString() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            StringBuilder res = new StringBuilder();
            do {
                if (Character.isValidCodePoint(c)) {
                    res.appendCodePoint(c);
                }
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public String next() {
            return readString();
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void print(Object... objects) {
            for (int i = 0; i < objects.length; i++) {
                if (i != 0) {
                    writer.print(' ');
                }
                writer.print(objects[i]);
            }
        }

        public void close() {
            writer.close();
        }

    }
}

import java.io.*;
import java.util.Arrays;

/**
 * Created by wannabe on 19.03.16.
 */
public class A {
	public static void writeData(String data) throws IOException {
		BufferedWriter log = new BufferedWriter(new OutputStreamWriter(System.out));
		log.write(data);
		log.flush();
	}

	public static void main(String[] args) throws IOException {
		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
			String[][] first = new String[2][2];
			String[][] second = new String[2][2];

			String[] split = br.readLine().split("");
			first[0][0] = split[0];
			first[0][1] = split[1];
			split = br.readLine().split("");
			first[1][0] = split[0];
			first[1][1] = split[1];

			split = br.readLine().split("");
			second[0][0] = split[0];
			second[0][1] = split[1];
			split = br.readLine().split("");
			second[1][0] = split[0];
			second[1][1] = split[1];

			String[][] firstInit = copy(first);
			do {
				rotate(true, first);
				if (Arrays.deepEquals(first, second)) {
					writeData("YES");
					return;
				}
			} while (!Arrays.deepEquals(first, firstInit));

			String[][] firstInitCopy = copy(firstInit);
			System.arraycopy( firstInit, 0, firstInitCopy, 0, firstInit.length );
			do {
				rotate(false, firstInitCopy);
				if (Arrays.deepEquals(firstInitCopy, second)) {
					writeData("YES");
					return;
				}
			} while (!Arrays.deepEquals(firstInit, firstInitCopy));
			writeData("NO");
		}
	}

	protected static String[][] copy(String[][] src) {
		String[][] dst = new String[2][2];
		for (int i = 0; i < 2; i++) {
			System.arraycopy(src[i], 0, dst[i], 0, 2);
		}
		return dst;
	}

	protected static void rotate(boolean clockwise, String[][] table) {
		int emptyX;
		int emptyY;
		for (int i = 0; i < table.length; i++) {
			for (int j = 0; j < table.length; j++) {
				if (table[i][j].equals("X")) {
					emptyX = i;
					emptyY = j;
					if (emptyX == 0) {
						if (emptyY == 0) {
							if (clockwise) {
								swap(emptyX, emptyY, 1, 0, table);
							} else {
								swap(emptyX, emptyY, 0, 1, table);
							}
						} else {
							if (clockwise) {
								swap(emptyX, emptyY, 0, 0, table);
							} else {
								swap(emptyX, emptyY, 1, 1, table);
							}
						}
					} else {
						if (emptyY == 0) {
							if (clockwise) {
								swap(emptyX, emptyY, 1, 1, table);
							} else {
								swap(emptyX, emptyY, 0, 0, table);
							}
						} else {
							if (clockwise) {
								swap(emptyX, emptyY, 0, 1, table);
							} else {
								swap(emptyX, emptyY, 1, 0, table);
							}
						}
					}
					return;
				}
			}
		}
		throw new RuntimeException();
	}

	protected static void swap(int x1, int y1, int x2, int y2, String[][] table) {
		String tmp = table[x1][y1];
		table[x1][y1] = table[x2][y2];
		table[x2][y2] = tmp;
	}
}

import java.io.PrintWriter;
import java.util.Scanner;

public class A {
    public static void main(String[] args) {
        try (Scanner scanner = new Scanner(System.in); PrintWriter writer = new PrintWriter(System.out)) {
            char[][] a = new char[2][];
            a[0] = scanner.next().toCharArray();
            a[1] = scanner.next().toCharArray();
            char[][] b = new char[2][];
            b[0] = scanner.next().toCharArray();
            b[1] = scanner.next().toCharArray();

            for (int i = 0; i < 1000; i++) {
                shift(a);
                if (equal(a, b)) {
                    writer.println("YES");
                    return;
                }
            }
            writer.println("NO");
        }
    }

    private static boolean equal(char[][] a, char[][] b) {
        for (int i = 0; i < a.length; i++) {
            for (int j = 0; j < a[0].length; j++) {
                if (a[i][j] != b[i][j]) {
                    return false;
                }
            }
        }
        return true;
    }

    private static void shift(char[][] a) {
        if (a[0][0] == 'X') {
            a[0][0] = a[1][0];
            a[1][0] = 'X';
        } else if (a[0][1] == 'X') {
            a[0][1] = a[0][0];
            a[0][0] = 'X';
        } else if (a[1][0] == 'X') {
            a[1][0] = a[1][1];
            a[1][1] = 'X';
        } else if (a[1][1] == 'X') {
            a[1][1] = a[0][1];
            a[0][1] = 'X';
        }
    }
}

import java.util.*;
import java.io.*;

//DONT FORGET TO CHANGE CLASS NAME!
public class AmityAssesment {
    /*
    This could be a hard ish problem where we have to search all possible
    perumtations. However if we recognize that we can only rotate around the board
    Then we figure out that we just need to ensure the characters all come in the same order
    That is, can we cycle one string to get the other
    We can do this by creating the string in the CCW order
    we want to check the order 1 2 3 4 ignoring the X
    Let the upper left be 1
    we will call lower left 2, lower right 3, and upper right 4
    We create the string corresponding to 1 2 3 4 for each input
    and then remove X
    and check if one string is a 1-shift permuatation of the other

    */
    static boolean testing = false; //change to false on submission
    static String name = "CodeForcesTemplate"; // insert the class name here
    public static void main(String[] args) throws IOException {
        Scanner input;
        PrintWriter writer;
        if(testing){input = new Scanner(new FileReader(name+".in"));writer = new PrintWriter(name+".out");}else{input = new Scanner(System.in);writer = new PrintWriter(System.out);}
        //Declare Variables
        StringTokenizer tokenizer;
        String s1, s2;
        char a, b;
        //read input, execute program
        tokenizer = new StringTokenizer(input.nextLine());
        s1 = tokenizer.nextToken();
        a = s1.charAt(0);
        b = s1.charAt(1);
        tokenizer = new StringTokenizer(input.nextLine());
        s1 = a + tokenizer.nextToken() + b;
        s1 = s1.replace("X","");
        s1 = s1.substring(s1.indexOf("A")) + s1.substring(0, s1.indexOf("A"));

        tokenizer = new StringTokenizer(input.nextLine());
        s2 = tokenizer.nextToken();
        a = s2.charAt(0);
        b = s2.charAt(1);
        tokenizer = new StringTokenizer(input.nextLine());
        s2 = a + tokenizer.nextToken() + b;
        s2 = s2.replace("X","");
        s2 = s2.substring(s2.indexOf("A")) + s2.substring(0, s2.indexOf("A"));
        if(s1.equals(s2)){writer.println("YES");}
        else{writer.println("NO");}

        writer.close();
        input.close();
    }

    }//Class Close Bracket

import java.util.*;
import java.io.*;

//DONT FORGET TO CHANGE CLASS NAME!
public class AmityAssesment {
    /*
    This could be a hard ish problem where we have to search all possible
    perumtations. However if we recognize that we can only rotate around the board
    Then we figure out that we just need to ensure the characters all come in the same order
    That is, can we cycle one string to get the other
    We can do this by creating the string in the CCW order
    we want to check the order 1 2 3 4 ignoring the X
    Let the upper left be 1
    we will call lower left 2, lower right 3, and upper right 4
    We create the string corresponding to 1 2 3 4 for each input
    and then remove X
    and check if one string is a 1-shift permuatation of the other

    */
    static boolean testing = false; //change to false on submission
    static String name = "CodeForcesTemplate"; // insert the class name here
    public static void main(String[] args) throws IOException {
        Scanner input;
        PrintWriter writer;
        if(testing){input = new Scanner(new FileReader(name+".in"));writer = new PrintWriter(name+".out");}else{input = new Scanner(System.in);writer = new PrintWriter(System.out);}
        //Declare Variables
        StringTokenizer tokenizer;
        String s1, s2;
        char a, b;
        //read input, execute program
        tokenizer = new StringTokenizer(input.nextLine());
        s1 = tokenizer.nextToken();
        a = s1.charAt(0);
        b = s1.charAt(1);
        tokenizer = new StringTokenizer(input.nextLine());
        s1 = a + tokenizer.nextToken() + b;
        s1 = s1.replace("X","");

        tokenizer = new StringTokenizer(input.nextLine());
        s2 = tokenizer.nextToken();
        a = s2.charAt(0);
        b = s2.charAt(1);
        tokenizer = new StringTokenizer(input.nextLine());
        s2 = a + tokenizer.nextToken() + b;
        s2 = s2.replace("X","");
        s2 = s2 + s2;
        if(s2.contains(s1)){writer.println("YES");}
        else{writer.println("NO");}

        writer.close();
        input.close();
    }

    }//Class Close Bracket

import java.io.*;
import java.util.*;
public class Main implements Runnable{

    private void solve()throws IOException{
        String a="";
        String b="";
        String s[]=new String[4];
        for(int i=0;i<4;i++)
            s[i]=nextLine();
        if(s[0].charAt(0)!='X')
            a+=s[0].charAt(0);
        if(s[0].charAt(1)!='X')
            a+=s[0].charAt(1);
        if(s[1].charAt(1)!='X')
            a+=s[1].charAt(1);
        if(s[1].charAt(0)!='X')
            a+=s[1].charAt(0);

        if(s[2].charAt(0)!='X')
            b+=s[2].charAt(0);
        if(s[2].charAt(1)!='X')
            b+=s[2].charAt(1);
        if(s[3].charAt(1)!='X')
            b+=s[3].charAt(1);
        if(s[3].charAt(0)!='X')
            b+=s[3].charAt(0);

        while(b.charAt(0)!='A')
            b=b.substring(1,b.length())+b.charAt(0);
        while(a.charAt(0)!='A')
            a=a.substring(1,a.length())+a.charAt(0);
// debug(a,b);
        if(a.equals(b))
            out.println("YES");
        else
            out.println("NO");
    }

    ///////////////////////////////////////////////////////////

    final long mod=(long)(1e9+7);
    final int inf=(int)(1e9+1);
    final int maxn=(int)(1e6);
    final long lim=(long)(1e18);

    public void run(){
        try{
            br=new BufferedReader(new InputStreamReader(System.in));
            st=null;
            out=new PrintWriter(System.out);

            solve();

            // int t=nextInt();
            // for(int i=1;i<=t;i++){
            //     // out.print("Case #"+i+": ");
            //     solve();
            // }

            br.close();
            out.close();
        }catch(Exception e){
            e.printStackTrace();
            System.exit(1);
        }
    }
    public static void main(String args[])throws IOException{
        new Main().run();
    }
    int max(int ... a){
        int ret=a[0];
        for(int i=1;i<a.length;i++)
        ret=Math.max(ret,a[i]);
        return ret;
    }
    int min(int ... a){
        int ret=a[0];
        for(int i=1;i<a.length;i++)
        ret=Math.min(ret,a[i]);
        return ret;
    }
    void debug(Object ... a){
        System.out.print("> ");
        for(int i=0;i<a.length;i++)
        System.out.print(a[i]+" ");
        System.out.println();
    }
    void debug(int a[]){debuga(Arrays.stream(a).boxed().toArray());}
    void debug(long a[]){debuga(Arrays.stream(a).boxed().toArray());}
    void debuga(Object a[]){
        System.out.print("> ");
        for(int i=0;i<a.length;i++)
        System.out.print(a[i]+" ");
        System.out.println();
    }
    BufferedReader br;
    StringTokenizer st;
    PrintWriter out;
    String nextToken()throws IOException{
        while(st==null || !st.hasMoreTokens())
        st=new StringTokenizer(br.readLine());
        return st.nextToken();
    }
    String nextLine()throws IOException{
        return br.readLine();
    }
    int nextInt()throws IOException{
        return Integer.parseInt(nextToken());
    }
    long nextLong()throws IOException{
        return Long.parseLong(nextToken());
    }
    double nextDouble()throws IOException{
        return Double.parseDouble(nextToken());
    }
}

/*
 * PDPM IIITDM Jabalpur
 * Asutosh Rana
 */

import java.util.*;
import java.io.*;
import java.math.*;

public class Main
{
    static long MOD = 1000000007;
    public static void main (String[] args) throws java.lang.Exception
    {
        InputReader in=new InputReader(System.in);
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out=new PrintWriter(System.out);

        int t = 1;//in.readInt();
        for(int cas=1;cas<=t;cas++){
            char[] S1 = in.readCharA();
            char[] S2 = in.readCharA();
            char[] S3 = in.readCharA();
            char[] S4 = in.readCharA();

            char[] A = new char[3];
            char[] B = new char[6];

            int ptr = 0;
            if(S1[0]!='X')
                A[ptr++] = S1[0];
            if(S1[1]!='X')
                A[ptr++] = S1[1];
            if(S2[1]!='X')
                A[ptr++] = S2[1];
            if(S2[0]!='X')
                A[ptr++] = S2[0];

            ptr = 0;
            if(S3[0]!='X')
                B[ptr++] = S3[0];
            if(S3[1]!='X')
                B[ptr++] = S3[1];
            if(S4[1]!='X')
                B[ptr++] = S4[1];
            if(S4[0]!='X')
                B[ptr++] = S4[0];
            B[3] = B[0];
            B[4] = B[1];
            B[5] = B[2];

            int flag=0;
            for(int i=0;i<3;i++){
                if(A[0]==B[i] && A[1]==B[i+1] && A[2]==B[i+2])
                    flag=1;
            }
            if(flag==1)
                out.println("YES");
            else
                out.println("NO");
        }

        out.flush();
        out.close();
    }

}

class InputReader{
    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;
    private SpaceCharFilter filter;

    public InputReader(InputStream stream){this.stream = stream;}
    public int read(){
        if (numChars==-1) throw new InputMismatchException();
        if (curChar >= numChars){
            curChar = 0;
            try {numChars = stream.read(buf);}
            catch (IOException e){throw new InputMismatchException();}
            if(numChars <= 0) return -1;
        }
        return buf[curChar++];
    }

    public int readInt(){
        int c = read();
        while(isSpaceChar(c)) c = read();
        int sgn = 1;
        if (c == '-') {sgn = -1;c = read();}
        int res = 0;
        do {
            if(c<'0'||c>'9') throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = read();
        }
        while (!isSpaceChar(c)); return res * sgn;
    }

    public void readInt(int[] A){
        for(int i=0;i<A.length;i++)
            A[i] = readInt();
    }

    public long readLong() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        long res = 0;
        do {
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = read();
        }
        while (!isSpaceChar(c));
        return res * sgn;
    }

    public void readLong(long[] A){
        for(int i=0;i<A.length;i++)
            A[i] = readLong();
    }

    public double readDouble() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        double res = 0;
        while (!isSpaceChar(c) && c != '.') {
            if (c == 'e' || c == 'E')
                return res * Math.pow(10, readInt());
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = read();
        }
        if (c == '.') {
            c = read();
            double m = 1;
            while (!isSpaceChar(c)) {
                if (c == 'e' || c == 'E')
                    return res * Math.pow(10, readInt());
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                m /= 10;
                res += (c - '0') * m;
                c = read();
            }
        }
        return res * sgn;
    }

    public char[] readCharA(){
        return readString().toCharArray();
    }

    public String readString() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        StringBuilder res = new StringBuilder();
        do {
            res.appendCodePoint(c);
            c = read();
        } while (!isSpaceChar(c));
        return res.toString();
    }

    public boolean isSpaceChar(int c) {
        if (filter != null)
            return filter.isSpaceChar(c);
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    public String next() {
        return readString();
    }

    public interface SpaceCharFilter {
        public boolean isSpaceChar(int ch);
    }

}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

public class Main {
    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer buffer;

    public static String reverse(String s) {
        return new StringBuilder((s)).reverse().toString();
    }

    public static void solve() {
        StringBuilder a = new StringBuilder(), b = new StringBuilder();
        a.append(ns()).append(reverse(ns()));
        b.append(ns()).append(reverse(ns()));
        a.deleteCharAt(a.indexOf("X"));
        b.deleteCharAt(b.indexOf("X"));

        for (int shift=0;shift<3;shift++) {
            boolean equal = true;
            for (int i=0;i<3;i++) {
                if (a.charAt(i) != b.charAt((i+shift)%3)) equal = false;
            }
            if (equal) {
                out.println("YES");
                return;
            }
        }

        out.println("NO");
        return;
    }

    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        solve();
        out.close();
    }

    static String next() {
        while (buffer == null || !buffer.hasMoreElements()) {
            try {
                buffer = new StringTokenizer(in.readLine());
            } catch (IOException e) {
            }
        }
        return buffer.nextToken();
    }

    static int ni() {
        return Integer.parseInt(next());
    }

    static long nl() {
        return Long.parseLong(next());
    }

    static double nd() {
        return Double.parseDouble(next());
    }

    static String ns() {
        return next();
    }

    static int[] ni(int n) {
        int[] res = new int[n];
        for (int i = 0; i < n; i++)
            res[i] = Integer.parseInt(next());
        return res;
    }

    static long[] nl(int n) {
        long[] res = new long[n];
        for (int i = 0; i < n; i++)
            res[i] = Long.parseLong(next());
        return res;
    }

    static double[] nd(int n) {
        double[] res = new double[n];
        for (int i = 0; i < n; i++)
            res[i] = Double.parseDouble(next());
        return res;
    }

    static String[] ns(int n) {
        String[] res = new String[n];
        for (int i = 0; i < n; i++)
            res[i] = next();
        return res;
    }

}

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Solution {

	public void calc() throws Exception
	{

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String s;

		StringBuffer a = new StringBuffer();

		a.append(br.readLine());

		 s = br.readLine();
		//a.append(br.readLine().in);
		 a.append(s.charAt(1));
		 a.append(s.charAt(0));

		StringBuffer b = new StringBuffer();

		b.append(br.readLine());

		s = br.readLine();

		b.append(s.charAt(1));
		b.append(s.charAt(0));
		s = a.toString().replace("X", "");
		if ((s+s).contains(b.toString().replace("X","")))
				System.out.println("YES");
		else
			System.out.println("NO");

	}

	public static void main(String[] args) throws Exception{

		Solution sol = new Solution();

		sol.calc();

	}

}

import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class A655 {

	private static boolean home = !"true".equals(System.getProperty("ONLINE_JUDGE"));
	private static boolean debug = false;

	public static void main(String[] args) throws IOException {
		int nrTeste = 2;
String[] inputs = {"AB\nXC\nXB\nAC\n", "AB\nXC\nAC\nBX\n"};
String[] expected = {"YES\n", "NO\n"};
		for (int i = 0; home && i < nrTeste; i++) {
			System.out.print("\nExpect: " + expected[i] + "\n   Got: ");
			System.setIn(new ByteArrayInputStream(inputs[i].getBytes()));
			solve();
		}
		if (!home) {
			solve();
		}
		System.out.close();
	}

	public static void solve() throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw = new PrintWriter(System.out);
		String line1 = br.readLine();
		String s = br.readLine();
		line1 = line1 + s.charAt(1) + s.charAt(0);
		if (home) {
			System.out.println(line1);
		}
		while(line1.charAt(0) != 'X') {
			line1 = line1.substring(1) + line1.charAt(0);
		}
		if (home) {
			System.out.println(line1);
		}
		String line2 = br.readLine();
		s = br.readLine();
		line2 = line2 + s.charAt(1) + s.charAt(0);
		while(line2.charAt(0) != 'X') {
			line2 = line2.substring(1) + line2.charAt(0);
		}
		if (home) {
			System.out.println(line2);
		}
		boolean yes = false;
		for (int i = 0; i< 4; i++) {
			if (line1.equals(line2)){
				pw.println("YES");
				yes = true;
				break;
			}
			line2 = 'X' + line2.substring(2) + line2.charAt(1);
			if (home) {
				System.out.println(line2);

			}
		}
		if (!yes) {
			pw.println("NO");

		}
		br.close();
		pw.flush();
	}

}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class ProblemA {
    BufferedReader rd;

    ProblemA() throws IOException {
        rd = new BufferedReader(new InputStreamReader(System.in));
        compute();
    }

    private void compute() throws IOException {
        char[][] v = new char[4][];
        for(int i=0;i<4;i++) {
            v[i] = rd.readLine().toCharArray();
        }
        String s1 = get(new char[][] { v[0],v[1] });
        String s2 = get(new char[][] { v[2],v[3] });
        out(s1.equals(s2)?"YES":"NO");
    }

    private String get(char[][] a) {
        String res = "";
        boolean h = false;
        for(int k=0;k<4;k++) {
            for (int[] c : new int[][]{{0, 0}, {0, 1}, {1, 1}, {1, 0}}) {
                char d = a[c[0]][c[1]];
                if(h) {
                    if (d != 'X') {
                        res += d;
                    }
                } else {
                    if (d == 'X') {
                        h = true;
                    }
                }
            }
        }
        int ix = res.indexOf('A');
        return res.substring(ix,ix+3);
    }

    private static void out(Object x) {
        System.out.println(x);
    }

    public static void main(String[] args) throws IOException {
        new ProblemA();
    }
}

import java.io.InputStreamReader;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.BufferedWriter;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Writer;
import java.util.StringTokenizer;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author Andrey Rechitsky (arechitsky@gmail.com)
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		FastScanner in = new FastScanner(inputStream);
		FastPrinter out = new FastPrinter(outputStream);
		TaskA solver = new TaskA();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskA {
    public void solve(int testNumber, FastScanner in, FastPrinter out) {
        char [][]inp = new char[4][];
        for (int i = 0; i < 4; i++) {
            inp[i] = in.next().toCharArray();
        }
        char []s1 = new char[4];
        s1[0] = inp[0][0];
        s1[1] = inp[0][1];
        s1[2 ]= inp[1][1];
        s1[3] = inp[1][0];
        char []s2 = new char[4];
        s2[0] = inp[2][0];
        s2[1] = inp[2][1];
        s2[2 ]= inp[3][1];
        s2[3] = inp[3][0];
        boolean cl1 = true;
        char c = 0;
        for (int i = 0; i < 4; i++) {
            if (s1[i]=='X') continue;
            cl1 &= (c=='C' && s1[i]=='A') || s1[i]>c;
            c = s1[i];
        }
        boolean cl2 = true;
        c = 0;
        for (int i = 0; i < 4; i++) {
            if (s2[i]=='X') continue;
            cl2 &= (c=='C' && s2[i]=='A') || s2[i]>c;
            c = s2[i];
        }
        out.printLine(cl1==cl2?"YES":"NO");
    }
}

class FastScanner {

    private BufferedReader reader;
    private StringTokenizer st;

    public FastScanner(InputStream stream) {
        this.reader = new BufferedReader(new InputStreamReader(stream));
        this.st = new StringTokenizer("");
    }

    public String next() {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(readLine());
        }
        return st.nextToken();
    }

    private String readLine() {
        String line = tryReadLine();
        if (line == null) throw new InputMismatchException();
        return line;
    }

    private String tryReadLine() {
        try {
            return reader.readLine();
        } catch (IOException e) {
            throw new InputMismatchException();
        }
    }

}

class FastPrinter {
    private final PrintWriter writer;

    public FastPrinter(OutputStream outputStream) {
        writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
    }

    public void close() {
        writer.close();
    }

    public void printLine(String s) {
        writer.println(s);
    }

}

import java.util.*;
public class A {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		char[][] a = new char[2][2];
		char[][] b = new char[2][2];

		for(int i = 0; i < 2; i ++)
		{
			String s = in.next();
			for(int j = 0; j < 2; j ++)
				a[i][j] = s.charAt(j);
		}
		for(int i = 0; i < 2; i ++)
		{
			String s = in.next();
			for(int j = 0; j < 2; j ++)
				b[i][j] = s.charAt(j);
		}

		boolean ans = false;
		for(int i = 0; i < 12; i ++)
		{
			b = rotateRight(b);
			if(equals(a, b))
				ans = true;
		}
		for(int i = 0; i < 12; i ++)
		{
			b = rotateLeft(b);
			if(equals(a, b))
				ans = true;
		}
		System.out.println(ans?"YES":"NO");
	}
	static char[][] rotateRight(char[][] b)
	{
		char[][] a = new char[2][2];
		for(int i = 0; i < 2; i ++)
			for(int j = 0; j < 2; j ++)
				a[i][j] = b[i][j];

		boolean done = false;
		for(int i = 0; i < 2; i ++)
		{
			for(int j = 0; j < 2; j ++)
			{
				if(a[i][j] !='X')
					continue;
				if(i == 0 && j == 0)
				{
					char t = a[0][1];
					a[0][1] = a[0][0];
					a[0][0] = t;
				}
				if(i == 0 && j == 1)
				{
					char t = a[1][1];
					a[1][1] = a[0][1];
					a[0][1] = t;
				}
				if(i == 1 && j == 1)
				{
					char t = a[1][0];
					a[1][0] = a[1][1];
					a[1][1] = t;
				}
				if(i == 1 && j == 0)
				{
					char t = a[0][0];
					a[0][0] = a[1][0];
					a[1][0] = t;
				}
				done = true;
				break;
			}
			if(done)
				break;
		}
		return a;
	}
	static char[][] rotateLeft(char[][] b)
	{
		char[][] a = new char[2][2];
		for(int i = 0; i < 2; i ++)
			for(int j = 0; j < 2; j ++)
				a[i][j] = b[i][j];

		boolean done = false;
		for(int i = 0; i < 2; i ++)
		{
			for(int j = 0; j < 2; j ++)
			{
				if(a[i][j] !='X')
					continue;
				if(i == 0 && j == 0)
				{
					char t = a[1][0];
					a[1][0] = a[0][0];
					a[0][0] = t;
				}
				if(i == 0 && j == 1)
				{
					char t = a[0][0];
					a[0][0] = a[0][1];
					a[0][1] = t;
				}
				if(i == 1 && j == 1)
				{
					char t = a[0][1];
					a[0][1] = a[1][1];
					a[1][1] = t;
				}
				if(i == 1 && j == 0)
				{
					char t = a[1][1];
					a[1][1] = a[1][0];
					a[1][0] = t;
				}
				done = true;
				break;
			}
			if(done)
				break;
		}
		return a;
	}
	static boolean equals(char[][] a, char[][] b)
	{
		boolean equals = true;
		for(int i = 0; i < a.length; i ++)
			for(int j = 0; j < a[0].length; j ++)
				if(a[i][j] != b[i][j])
					equals = false;
		return equals;
	}
}

import java.io.*;    //PrintWriter
import java.math.*;  //BigInteger, BigDecimal
import java.util.*;  //StringTokenizer, ArrayList

public class CROC_2016_ER_A
{
	FastReader in;
	PrintWriter out;

	public static void main(String[] args)  {
		new CROC_2016_ER_A().run();
	}

	void run()
	{
		in = new FastReader(System.in);
		out = new PrintWriter(System.out);
		solve();
		out.close();
	}

	void solve()
	{
		String b1 = in.next(), b2 = in.next();
		String e1 = in.next(), e2 = in.next();
		String b = (b1 + b2.charAt(1) + b2.charAt(0)).replace("X","");
		String e = (e1 + e2.charAt(1) + e2.charAt(0)).replace("X","");
		boolean ok = false;
		for (int i = 0; i < 3; i++)
		{
			if (b.equals(e)) ok = true;
			b = b.substring(2) + b.substring(0,2);
		}

		out.println(ok ? "YES" : "NO");
	}

	//-----------------------------------------------------
	void runWithFiles() {
		in = new FastReader(new File("input.txt"));
		try {
			out = new PrintWriter(new File("output.txt"));
		}
		catch (FileNotFoundException e) {
			e.printStackTrace();
		}
		solve();
		out.close();
	}

	class FastReader
	{
	    BufferedReader br;
	    StringTokenizer tokenizer;

	    public FastReader(InputStream stream)
	    {
	        br = new BufferedReader(new InputStreamReader(stream));
	        tokenizer = null;
	    }
		public FastReader(File f) {
			try {
				br = new BufferedReader(new FileReader(f));
				tokenizer = null;
			}
			catch (FileNotFoundException e) {
				e.printStackTrace();
			}
		}

	    private String next() {
	        while (tokenizer == null || !tokenizer.hasMoreTokens())
	            try {
	            	tokenizer = new StringTokenizer(br.readLine());
	            }
	            catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        return tokenizer.nextToken();
	    }
		public String nextLine() {
			try	{
				return br.readLine();
			}
			catch(Exception e) {
				throw(new RuntimeException());
			}
		}

	    int nextInt() {
	        return Integer.parseInt(next());
	    }
	    long nextLong() {
	        return Long.parseLong(next());
	    }
	    double nextDouble() {
	        return Double.parseDouble(next());
	    }
	    BigInteger nextBigInteger() {
	        return new BigInteger(next());
	    }
	    BigDecimal nextBigDecimal() {
	        return new BigDecimal(next());
	    }
	}
}

import java.io.*;
import java.math.*;
import java.util.*;

public class main {

    private static PrintWriter out;
    private static class FastScanner {
        BufferedReader br;
        StringTokenizer st;
        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

    }

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));

        char[] a1 = sc.nextLine().toCharArray();
        char[] a2= sc.nextLine().toCharArray();
        char[] b1 = sc.nextLine().toCharArray();
        char[] b2= sc.nextLine().toCharArray();

        char [][] a = new char[2][];
        a[0] = a1;
        a[1] = a2;

        char [][] b = new char[2][];
        b[0] = b1;
        b[1] = b2;

        boolean flag = false;

        for(int i = 0; i < 5; i ++)
        {
        	if(equal(shiftLeft(a), b) || equal(shiftUp(a), b) || equal(shiftRight(a), b) || equal(shiftDown(a), b))
        	{
        		flag = true;
        		out.println("YES");
        		break;
        	}
        }
        if(!flag)
	        for(int i = 0; i < 5; i ++)
	        {
	        	if(equal(shiftLeft(b), a) || equal(shiftUp(b), a) || equal(shiftRight(b), a) || equal(shiftDown(b), a))
	        	{
	        		flag = true;
	        		out.println("YES");
	        		break;
	        	}
	        }

        if(!flag) out.println("NO");

        out.close();
    }

    static char[][] shiftUp(char[][] val)
    {
    	char [][] m_val = val;
    	if(val[0][0]=='X')
    	{
    		m_val[0][0] = val[1][0];
    		m_val[1][0] = 'X';
    	}else if(val[0][1]=='X')
    	{
    		m_val[0][1] = val[1][1];
    		m_val[1][1] = 'X';
    	}
    	return m_val;
    }
    static char[][] shiftDown(char[][] val)
    {
    	char [][] m_val = val;
    	if(val[1][0]=='X')
    	{
    		m_val[1][0] = val[0][0];
    		m_val[0][0] = 'X';
    	}else if(val[1][1]=='X')
    	{
    		m_val[1][1] = val[0][1];
    		m_val[0][1] = 'X';
    	}
    	return m_val;
    }

    static char[][] shiftLeft(char[][] val)
    {
    	char [][] m_val = val;
    	if(val[0][0]=='X')
    	{
    		m_val[0][0] = val[0][1];
    		m_val[0][1] = 'X';
    	}else if(val[1][0]=='X')
    	{
    		m_val[1][0] = val[1][1];
    		m_val[1][1] = 'X';
    	}
    	return m_val;
    }

    static char[][] shiftRight(char[][] val)
    {
    	char [][] m_val = val;
    	if(val[0][1]=='X')
    	{
    		m_val[0][1] = val[0][0];
    		m_val[0][0] = 'X';
    	}else if(val[1][1]=='X')
    	{
    		m_val[1][1] = val[1][0];
    		m_val[1][0] = 'X';
    	}
    	return m_val;
    }

    static void print(char[][] val)
    {
    	System.out.print(""+val[0][0]+val[0][1]+"\n"+val[1][0]+val[1][1]+"\n");
    }

    static boolean equal(char[][] a, char[][] b)
    {
    	return a[0][0] == b[0][0] && a[0][1] == b[0][1]
    			&& a[1][0] == b[1][0] && a[1][1] == b[1][1];
    }
}

import java.util.*;
import java.io.*;

public class A {
    FastScanner in;
    PrintWriter out;

    int[][] sh = new int[][] {
            {1, 2},
            {0, 3},
            {0, 3},
            {1, 2}
    };

    public void solve() throws IOException {
        String s = in.next() + in.next();
        String t = in.next() + in.next();

        String[] q = new String[10000];
        int head = 0;
        int tail = 1;
        q[head] = s;
        Set<String> was = new HashSet<>();
        was.add(s);
        while (head < tail) {
            char[] cur = q[head++].toCharArray();
            int emp = q[head - 1].indexOf("X");
            for (int x : sh[emp]) {
                char tmp = cur[x];
                cur[x] = cur[emp];
                cur[emp] = tmp;

                String n = new String(cur);
                if (n.equals(t)) {
                    out.println("YES");
                    return;
                }
                if (!was.contains(n)) {
                    was.add(n);
                    q[tail++] = n;
                }
                tmp = cur[x];
                cur[x] = cur[emp];
                cur[emp] = tmp;
            }
        }
        out.println("NO");

    }

    public void run() {
        try {
            in = new FastScanner(System.in);
            out = new PrintWriter(System.out);
            Locale.setDefault(Locale.US);

            solve();

            out.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        FastScanner(InputStream f) {
            br = new BufferedReader(new InputStreamReader(f));
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }
    }

    public static void main(String[] arg) {
        new A().run();
    }
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String A = in.next();
            String B = in.next();
            String C = in.next();
            String D = in.next();

            String AB = A + rev(B);
            String CD = C + rev(D);

            String sec = CD + CD;

            String ABx = AB.substring(0, AB.indexOf('X')) + AB.substring(AB.indexOf('X') + 1);

            for (int i = 0; i <= 3; i++) {
                String tmp = ABx.substring(0, i) + 'X' + ABx.substring(i);
                if (sec.contains(tmp)) {
                    out.println("YES");
                    return;
                }
            }
            out.println("NO");
        }

        private String rev(String str) {
            return "" + str.charAt(1) + "" + str.charAt(0) + "";
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

    }
}

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(new BufferedInputStream(System.in));
        PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));

        char[] a = new char[3];
        int i =0;
        for (char c : in.next().toCharArray()) {
            if(c!='X'){
                a[i] = c;
                i++;
            }
        }
        i=0;
        for (char c : in.next().toCharArray()) {
            if(c!='X'){
                a[2-i] = c;
                i++;
            }
        }

        char[] b = new char[3];
        i =0;
        for (char c : in.next().toCharArray()) {
            if(c!='X'){
                b[i] = c;
                i++;
            }
        }
        i=0;
        for (char c : in.next().toCharArray()) {
            if(c!='X'){
                b[2-i] = c;
                i++;
            }
        }

        boolean result = true;
        int ptr = -1;
        for (int j = 0; j < 3; j++) {
            if(a[0]==b[j]){
                ptr = j;
                break;
            }
        }

        if(ptr >=0){
            for (int j = 0; j < 3; j++) {
                if(a[j]!=b[(j+ptr)%3]){
                    result = false;
                    break;
                }
            }
        }else{
            result = false;
        }

        if(result){
            out.println("YES");
        } else {
            out.println("NO");
        }

        in.close();
        out.close();
    }

}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String conf1 = (in.nextLine() + new StringBuilder(in.nextLine()).reverse().toString()).replaceAll("X", "");
            String conf2 = (in.nextLine() + new StringBuilder(in.nextLine()).reverse().toString()).replaceAll("X", "");

            for (int i = 0; i < 10; i++) {
                if (conf1.equals(conf2)) {
                    out.println("YES");
                    return;
                }
                char c = conf1.charAt(0);
                conf1 = conf1.substring(1) + c;
            }
            out.println("NO");
        }

    }
}

import java.util.Scanner;

public class AmityAssesment {

	public static void main(String[] args) {
		// TODO Auto-generated method stub

		Scanner input = new Scanner(System.in);
		String a = input.next();
	   a+=reverse(input.next());
	   String b = input.next();
	   b+=reverse(input.next());
	   if(a.equals(b)){
		   System.out.println("YES");
	     return;
	   }
	     String p=a;
	   a = next(a);
	  //System.out.println(b+" "+a);
	  while(!p.equals(a)){
		 // System.out.println(a+" "+b);
		  if(a.equals(b)){
			  System.out.println("YES");
		     return;
		  }
		  a = next(a);
	  }
	  System.out.println("NO");
	}

	private static String reverse(String s){
		String z = "";
		for(int i=s.length()-1; i>=0;i--)z+=s.charAt(i);
		return z;
	}

	private static String next(String s){
		int i = s.indexOf("X");
		String z = "";
		if(i!=s.length()-1){
			z+=s.substring(0,i);
		z+=reverse(s.substring(i,i+2));
		z+=s.substring(i+2);
			return z;
		}
		else{
			z+=s.charAt(s.length()-1)+s.substring(1,s.length()-1)+s.charAt(0);
			return z;
		}
	}

}

import java.io.*;
import java.util.Locale;
import java.util.StringTokenizer;

public class A implements Runnable {

    private static final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;

    private BufferedReader in;
    private PrintWriter out;
    private StringTokenizer tok = new StringTokenizer("");

    private void init() throws FileNotFoundException {
        Locale.setDefault(Locale.US);
        String fileName = "";
        if (ONLINE_JUDGE && fileName.isEmpty()) {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
        } else {
            if (fileName.isEmpty()) {
                in = new BufferedReader(new FileReader("input.txt"));
                out = new PrintWriter("output.txt");
            } else {
                in = new BufferedReader(new FileReader(fileName + ".in"));
                out = new PrintWriter(fileName + ".out");
            }
        }
    }

    String readString() {
        while (!tok.hasMoreTokens()) {
            try {
                tok = new StringTokenizer(in.readLine());
            } catch (Exception e) {
                return null;
            }
        }
        return tok.nextToken();
    }

    int readInt() {
        return Integer.parseInt(readString());
    }

    long readLong() {
        return Long.parseLong(readString());
    }

    double readDouble() {
        return Double.parseDouble(readString());
    }

    int[] readIntArray(int size) {
        int[] a = new int[size];
        for (int i = 0; i < size; i++) {
            a[i] = readInt();
        }
        return a;
    }

    public static void main(String[] args) {
        //new Thread(null, new _Solution(), "", 128 * (1L << 20)).start();
        new A().run();
    }

    long timeBegin, timeEnd;

    void time() {
        timeEnd = System.currentTimeMillis();
        System.err.println("Time = " + (timeEnd - timeBegin));
    }

    @Override
    public void run() {
        try {
            timeBegin = System.currentTimeMillis();
            init();
            solve();
            out.close();
            time();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(-1);
        }
    }

    private void solve() {
        String s = readString();
        String buf = readString();
        s = s + buf.charAt(1) + buf.charAt(0);
        s = s.replace("X", "");
        s = s + s;

        String t = readString();
        buf = readString();
        t = t + buf.charAt(1) + buf.charAt(0);
        t = t.replace("X", "");
        out.println(s.contains(t) ? "YES" : "NO");
    }
}

import java.util.*;
import java.io.*;

public class CF655A_2{
  public static int index;
  public static void main(String[] args)throws Exception {
    InputReader in = new InputReader(System.in);
    PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out));
  //  int n = in.nextInt();
    char[] a = in.next().toCharArray(), b = in.next().toCharArray();
    char[] c = in.next().toCharArray(), d = in.next().toCharArray();

    String up = ""+a[0]+b[0]+b[1]+a[1];
    String dn = ""+c[0]+d[0]+d[1]+c[1];

    for(int i = 0; i < 6; i++){
      int idx = dn.indexOf('X');
      dn = swap(dn, idx);
     // System.out.println(dn);
      if(isSame(up, dn)){
        System.out.println("YES");
        return;
      }
    }

    System.out.println("NO");

    pw.close();
  }
  static boolean isSame(String a , String b){
    for(int i = 0; i < 6; i++){
      b = swapLast(b);
   //   System.err.println(b);
      if(a.equals(b)) return true;
    }
    return false;
  }

  static String swapLast(String s){
    s = s+" ";
    char [] a = s.toCharArray();
    a[4] = a[0];
    a[0] = ' ';
    return String.valueOf(a).trim();
  }
  static String swap(String s, int i){
    char [] a = s.toCharArray();

    if(i == 3){
      char t = a[i];
      a[i] = a[0];
      a[0] = t;
    }
    else{
      char t = a[i];
      a[i] = a[i+1];
      a[i+1] = t;
    }
    return String.valueOf(a);
  }

  static class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
      reader = new BufferedReader(new InputStreamReader(stream));
      tokenizer = null;
    }

    public String next() {

      try {
        while (tokenizer == null || !tokenizer.hasMoreTokens())
          tokenizer = new StringTokenizer(reader.readLine());
      } catch (IOException e) {
        return null;
      }

      return tokenizer.nextToken();
    }

    public String nextLine() {
      String line = null;
      try {
        tokenizer = null;
        line =  reader.readLine();
      } catch (IOException e) {
        throw new RuntimeException(e);
      }
      return line;
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public long nextLong() {
      return Long.parseLong(next());
    }
    public boolean hasNext(){
      try {
        while (tokenizer == null || !tokenizer.hasMoreTokens())
          tokenizer = new StringTokenizer(reader.readLine());
      }
      catch (Exception e) {
        return false;
      }

    return true;

    }
  }
}

import java.util.Arrays;
import java.util.Scanner;

public class P655A
{
	public static void main(String[] args)
	{
		Scanner scan = new Scanner(System.in);
		char[][] bessie = new char[2][2];
		for (int i = 0; i < 2; i++)
			bessie[i] = scan.nextLine().toCharArray();
		char[][] elsie = new char[2][2];
		for (int i = 0; i < 2; i++)
			elsie[i] = scan.nextLine().toCharArray();
		for (int i = 0; i < 12; i++)
		{
			if (Arrays.deepEquals(bessie, elsie))
			{
				System.out.println("YES");
				return;
			}
			bessie = rotateClockwise(bessie);
		}
		System.out.println("NO");
		scan.close();
	}
	//moves the X clockwise
	private static char[][] rotateClockwise(char[][] arr)
	{
		if (arr[0][0] == 'X')
			return new char[][] { { arr[0][1], arr[0][0] },{ arr[1][0], arr[1][1] } };
		if (arr[0][1] == 'X')
			return new char[][] { { arr[0][0], arr[1][1] },{ arr[1][0], arr[0][1] } };
		if (arr[1][1] == 'X')
			return new char[][] { { arr[0][0], arr[0][1] },{ arr[1][1], arr[1][0] } };
		return new char[][] { { arr[1][0], arr[0][1] },{ arr[0][0], arr[1][1] } };
	}
}

import java.util.*;
import java.io.*;

public class TaskA {
    private FastScanner in;
    private PrintWriter out;

    public void solve() throws IOException {
        String a = in.next();
        String b = in.next();
        String c = in.next();
        String d = in.next();
        a += b.charAt(1);
        a += b.charAt(0);
        c += d.charAt(1);
        c += d.charAt(0);

        String help1 = a.substring(0, a.indexOf("X")) + (a.indexOf("X") == a.length() - 1 ?
                "" : a.substring(a.indexOf("X") + 1));
        String help2 = c.substring(0, c.indexOf("X")) + (c.indexOf("X") == c.length() - 1 ?
                "" : c.substring(c.indexOf("X") + 1));
        help1 += help1;
        for (int i = 0; i < help1.length() - help2.length(); i++) {
            if (help1.substring(i ,i + help2.length()).equals(help2)) {
                out.print("YES");
                return;
            }
        }
        out.print("NO");
    }

    public void run() {
        try {
            in = new FastScanner();
            out = new PrintWriter(System.out);
            solve();
            out.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    private class FastScanner {
        private BufferedReader br;
        private StringTokenizer st;

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

    }

    public static void main(String[] arg) {
        new TaskA().run();
    }
}

import java.util.Scanner;

public class A {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in = new Scanner(System.in);
		char[] a = new char[3];
		char[] b = new char[3];
		String s1 = in.next();
		String s2 = in.next();
		int i = 0;
		if (s1.charAt(0) != 'X') {
			a[i] = s1.charAt(0);
			i++;
		}
		if (s1.charAt(1) != 'X') {
			a[i] = s1.charAt(1);
			i++;
		}
		if (s2.charAt(1) != 'X') {
			a[i] = s2.charAt(1);
			i++;
		}
		if (s2.charAt(0) != 'X') {
			a[i] = s2.charAt(0);
			i++;
		}
		s1 = in.next();
		s2 = in.next();
		i = 0;
		if (s1.charAt(0) != 'X') {
			b[i] = s1.charAt(0);
			i++;
		}
		if (s1.charAt(1) != 'X') {
			b[i] = s1.charAt(1);
			i++;
		}
		if (s2.charAt(1) != 'X') {
			b[i] = s2.charAt(1);
			i++;
		}
		if (s2.charAt(0) != 'X') {
			b[i] = s2.charAt(0);
			i++;
		}
		for (int j = 0; j < b.length; j++) {
			if (b[j] == a[0]) {
				if (b[(j + 1) % 3] == a[1]) {
					System.out.println("YES");
					return;
				} else {
					System.out.println("NO");
					return;
				}
			}
		}
	}

}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Bessie {

	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		char bessie[][] = new char[2][2];
		String s1 = br.readLine();
		String s2 = br.readLine();

		String order = "";

		order = s1 + s2.charAt(1) + s2.charAt(0);

		s1 = br.readLine();
		s2 = br.readLine();

		if (order.charAt(0) == 'X') {
			String ot = "";
			for (int i = 1, count = 0; count < 4; count++, i++) {
				i %= 4;
				ot += order.charAt(i);
			}
			order = ot;
		}

		String order2 = "";

		order2 = s1 + s2.charAt(1) + s2.charAt(0);

		char first = order.charAt(0);

		int i = 0;
		while (order2.charAt(i) != first) {
			i++;
		}

		String ox = "" + order2.charAt(i);
		for (int tt = i + 1, count = 1; count < 4; ++tt, count++) {
			tt %= 4;
			ox += order2.charAt(tt);
		}

		order2 = ox;

	//	System.out.println(order + " " + order2);

		int j = 0;
		for (i = 0, j = 0; i < 4 && j < 4; j++, i++)
			if (order.charAt(i) != order2.charAt(j)) {
				if (order.charAt(i) == 'X') {
					j--;
				} else if (order2.charAt(j) == 'X') {
					i--;
				} else {
					System.out.println("NO");
					return;
				}
			}

		System.out.println("YES");
	}
}

import java.io.*;

public final class AmityAssessment {
	public static void main(String args[])throws java.lang.Exception{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        OutputStream out=new BufferedOutputStream(System.out);
        String str1=br.readLine();
        String str2=br.readLine();
        String str3=br.readLine();
        String str4=br.readLine();
        char a[]=str1.toCharArray();
        char b[]=str2.toCharArray();
        char c[]=str3.toCharArray();
        char d[]=str4.toCharArray();
        char x[]=new char[4];
        x[0]=a[0];
        x[1]=a[1];
        x[2]=b[1];
        x[3]=b[0];
        char y[]=new char[4];
        y[0]=c[0];
        y[1]=c[1];
        y[2]=d[1];
        y[3]=d[0];
        int p=0,q=0;
        for(int i=0;i<4;i++){
        	if(x[i]=='A')
        		p=i;
        	if(y[i]=='A')
        		q=i;
        }
        if(x[(p+1)%4]=='X')
        	p++;
        if(y[(q+1)%4]=='X')
        	q++;
        if(x[(p+1)%4]==y[(q+1)%4])
        	 out.write(("YES"+"\n").getBytes());
        else
        	 out.write(("NO"+"\n").getBytes());
        out.flush();

}
}

import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

public class CROC2016A1 {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		char[][] grid = new char[2][2];
		char[][] ans = new char[2][2];
		String in1 = scan.nextLine();
		String in2 = scan.nextLine();
		String in3 = scan.nextLine();
		String in4 = scan.nextLine();
		grid[0][0] = in1.charAt(0);
		grid[0][1] = in1.charAt(1);
		grid[1][0] = in2.charAt(0);
		grid[1][1] = in2.charAt(1);
		ans[0][0] = in3.charAt(0);
		ans[0][1] = in3.charAt(1);
		ans[1][0] = in4.charAt(0);
		ans[1][1] = in4.charAt(1);
		for(int i = 0; i < 16; i++){
			if(Arrays.deepEquals(grid, ans)){
				System.out.println("YES");
				return;
			}
			BREAK:
			for(int j = 0; j < 2; j++){
				for(int k = 0; k < 2; k++){
					if(grid[j][k] == 'X'){
						if(j == 0 && k == 0){
							grid[j][k] = grid[0][1];
							grid[0][1] = 'X';
						}
						else if(j == 0 && k == 1){
							grid[j][k] = grid[1][1];
							grid[1][1] = 'X';
						}
						else if(j == 1 && k == 1){
							grid[j][k] = grid[1][0];
							grid[1][0] = 'X';
						}
						else if(j == 1 && k == 0){
							grid[j][k] = grid[0][0];
							grid[0][0] = 'X';
						}
						break BREAK;
					}
				}
			}
		}
		System.out.println("NO");
		out.println();
		out.flush();
		out.close();
	}

}

import java.util.*;
import java.io.*;

public class A {

	static BufferedReader br;
	static PrintWriter out;
	static StringTokenizer st;

	public static void main (String[] args) throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(new OutputStreamWriter(System.out));
		//br = new BufferedReader(new FileReader("in.txt"));
		//out = new PrintWriter(new FileWriter("out.txt"));

		String s1 = readLine();
		s1 += new StringBuilder(readLine()).reverse();

		String s2 = readLine();
		s2 += new StringBuilder(readLine()).reverse();

		String res1 = "";
		for (int i = 0; i < 4; i++)
			if (s1.charAt(i) != 'X')
				res1 += s1.charAt(i);

		String res2 = "";
		for (int i = 0; i < 4; i++)
			if (s2.charAt(i) != 'X')
				res2 += s2.charAt(i);

//		res1 = new StringBuilder(res1).reverse().toString();

		if ((res1+res1).indexOf(res2) != -1)
			out.println("YES");
		else
			out.println("NO");

		out.close();
	}

	static String get (char[][] g1) {
		String s1 = "";
		if (g1[0][0] == 'X')
			s1 += ""+g1[1][0] + g1[0][1] + g1[1][1];
		else if (g1[0][1] == 'X')
			s1 += ""+g1[0][0] + g1[1][1] + g1[1][0];
		else if (g1[1][1] == 'X')
			s1 += ""+g1[0][0] + g1[0][1] + g1[1][0];
		else if (g1[1][0] == 'X')
			s1 += ""+g1[0][0] + g1[0][1] + g1[1][1];
		return s1;
	}

	static String next () throws IOException {
		while (st == null || !st.hasMoreTokens())
			st = new StringTokenizer(br.readLine().trim());
		return st.nextToken();
	}

	static long readLong () throws IOException {
		return Long.parseLong(next());
	}

	static int readInt () throws IOException {
		return Integer.parseInt(next());
	}

	static double readDouble () throws IOException {
		return Double.parseDouble(next());
	}

	static char readCharacter () throws IOException {
		return next().charAt(0);
	}

	static String readLine () throws IOException {
		return br.readLine().trim();
	}
}

import java.io.*;
import java.util.*;

public class Main {

	static char[][] a = new char[2][2];
	static char[][] b = new char[2][2];

	public static void main(String args[]) {

		Scanner in;
		try {
			in = new Scanner(new File("input.txt"));
		} catch (Exception e) {
			in = new Scanner(System.in);
		}

		String res = "NO";

		for (int i = 0; i < 2; ++i) {
			String str = in.nextLine();
			a[i][0] = str.charAt(0);
			a[i][1] = str.charAt(1);
		}

		for (int i = 0; i < 2; ++i) {
			String str = in.nextLine();
			b[i][0] = str.charAt(0);
			b[i][1] = str.charAt(1);
		}

		for (int i = 0; i < 12; ++i) {
			move();
			if (isEqual()) {
				res = "YES";
				break;
			}
		}

		System.out.println(res);
	}

	static boolean isEqual() {
		boolean eq = true;
		for (int i = 0; i < 2; ++i) {
			for (int j = 0; j < 2; ++j) {
				if (a[i][j] != b[i][j]) {
					eq = false;
				}
			}
		}
		return eq;
	}

	static void move() {
		char tmp = 'e';
		if (a[0][0] == 'X') {
			tmp = a[0][1];
			a[0][1] = 'X';
			a[0][0] = tmp;
		}
		else if (a[0][1] == 'X') {
			tmp = a[1][1];
			a[1][1] = 'X';
			a[0][1] = tmp;
		}
		else if (a[1][0] == 'X') {
			tmp = a[0][0];
			a[0][0] = 'X';
			a[1][0] = tmp;
		}
		else if (a[1][1] == 'X') {
			tmp = a[1][0];
			a[1][0] = 'X';
			a[1][1] = tmp;
		}
	}
}

import java.io.*;
import java.util.StringTokenizer;

public class Main {

    private static final double EPS = 1e-9;

    public static void main(String[] args) throws Exception {
        FastScanner fastScanner = new FastScanner(System.in);
        PrintWriter printWriter = new PrintWriter(System.out);
        Main main = new Main();
        main.solveA(fastScanner, printWriter);
        printWriter.close();

    }

    public void solveA(FastScanner scanner, PrintWriter writer) {
        String f1 = scanner.next();
        String f2 = scanner.next();
        f1 = f1.replace("X","");
        f2 = f2.replace("X","");

        String f3 = scanner.next();
        String f4 = scanner.next();
        f3 = f3.replace("X","");
        f4 = f4.replace("X","");

        String first = f1 + new StringBuffer(f2).reverse().toString();
        String second = f3 + new StringBuffer(f4).reverse().toString();
        boolean possible = false;
        for (int i = 0; i < 3; i++) {
            int j = 0;
            for (; j < 3; j++) {
                if (first.charAt((i + j) % 3) != second.charAt(j))
                    break;
            }
            if (j == 3) {
                possible = true;
                break;
            }
        }

        if (possible) {
            writer.printf("YES\n");
        } else {
            writer.print("NO\n");
        }

    }

    static class Point {
        long x, y;

        public Point(long x, long y) {
            this.x = x;
            this.y = y;
        }
    }

    long twoTimesAreaOfTriangle(Point a, Point b, Point c) {
        long ar = a.x * (b.y - c.y) + b.x * (c.y - a.y) + c.x * (a.y - b.y);
        if (ar < 0) ar = ar * (-1);
        return ar;
    }

    boolean isCisOnAB(Point a, Point b, Point c) {
        long cross = (c.y - a.y) * (b.x - a.x) - (c.x - a.x) * (b.y - a.y);
        if (cross != 0) return false;
        long dotproduct = (c.x - a.x) * (b.x - a.x) + (c.y - a.y) * (b.y - a.y);
        if (dotproduct < 0)
            return false;
        long squaredlengthba = (b.x - a.x) * (b.x - a.x) + (b.y - a.y) * (b.y - a.y);
        if (dotproduct > squaredlengthba) return false;

        return true;

    }

    static class FastScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        public String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                    return next();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

    }

}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String a = readPuzzle(in);
            String b = readPuzzle(in);
            if (a.equals(b)) {
                out.println("YES");
            } else {
                out.println("NO");
            }
        }

        private String readPuzzle(InputReader in) {
            char[][] a = new char[2][];
            a[0] = in.next().toCharArray();
            a[1] = in.next().toCharArray();
            String t = "";
            if (a[0][0] != 'X') t += a[0][0];
            if (a[0][1] != 'X') t += a[0][1];
            if (a[1][1] != 'X') t += a[1][1];
            if (a[1][0] != 'X') t += a[1][0];
            String res = t;
            for (int i = 1; i < t.length(); ++i) {
                String cur = t.substring(i) + t.substring(0, i);
                if (cur.compareTo(res) < 0) res = cur;
            }
            return res;
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

    }
}

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.math.BigInteger;
public class anjali{

    static class FastScanner{
        BufferedReader s;
        StringTokenizer st;

        public FastScanner(){
            st = new StringTokenizer("");
            s = new BufferedReader(new InputStreamReader(System.in));

        }

        public FastScanner(File f) throws FileNotFoundException{
            st = new StringTokenizer("");
            s = new BufferedReader (new FileReader(f));
        }

        public int nextInt() throws IOException{
            if(st.hasMoreTokens())
                return Integer.parseInt(st.nextToken());
            else{
                st = new StringTokenizer(s.readLine());
                return nextInt();
            }
        }

        public double nextDouble() throws IOException{
            if(st.hasMoreTokens())
                return Double.parseDouble(st.nextToken());
            else{
                st = new StringTokenizer(s.readLine());
                return nextDouble();
            }
        }

        public long nextLong() throws IOException{
            if(st.hasMoreTokens())
                return Long.parseLong(st.nextToken());
            else{
                st = new StringTokenizer(s.readLine());
                return nextLong();
            }
        }

        public String nextString() throws IOException{
            if(st.hasMoreTokens())
                return st.nextToken();
            else{
                st = new StringTokenizer(s.readLine());
                return nextString();
            }

        }

        public String readLine() throws IOException{
            return s.readLine();
        }

        public void close() throws IOException{
            s.close();
        }

    }      //Fastscanner class end

   static FastScanner in=new FastScanner();
   static PrintWriter ww=new PrintWriter(new OutputStreamWriter(System.out));
   public static void main(String args[])throws IOException
   {
   //Main ob=new Main();
   anjali ob=new anjali();
   ob.solve();
   ww.close();
   }
   public void solve()throws IOException
   {
	String f1 = in.nextString();
    String f2 = in.nextString();
    String f3 = in.nextString();
    String f4 = in.nextString();
    String s1 = f1.replace("X","");
    String s2 = f2.replace("X","");
    String s3 = f3.replace("X","");
    String s4 = f4.replace("X","");
    String first= s1+new StringBuffer(s2).reverse().toString();
    String second = s3+ new StringBuffer(s4).reverse().toString();
	boolean flag = false;
	for(int i=0;i<3;i++)
	 {
	   int j=0;
	   for(;j<3;j++)
	   {
	     if(first.charAt((i+j)%3)!=second.charAt(j))
		  break;
	   }
       if(j==3)
	   {
           flag = true;
           break;
	   }
     }
     if(flag)
       System.out.println("YES");
     else
         System.out.println("NO");

   }
  }

import java.io.*;
import java.util.*;
import java.*;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Random;
import java.lang.*;

import javax.naming.BinaryRefAddr;

public class zad {
private static BufferedReader in;
private static StringTokenizer tok;
private static PrintWriter out;
final static boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") !=null;

public static void init() throws FileNotFoundException{
if(ONLINE_JUDGE){
in = new BufferedReader(new InputStreamReader(System.in));
out = new PrintWriter(System.out);
}
else{
in = new BufferedReader(new FileReader("input.txt"));
out = new PrintWriter("out.txt");
}
}

private static String readString() throws IOException {
while (tok == null || !tok.hasMoreTokens()) {
tok = new StringTokenizer(in.readLine());
}
return tok.nextToken();
}

private static int readInt() throws IOException {
return Integer.parseInt(readString());
}
private static double readDouble() throws IOException {
return Double.parseDouble(readString());
}
private static long readLong() throws IOException {
return Long.parseLong(readString());
}
private static float readFloat() throws IOException{
    return Float.parseFloat(readString());
}

public static class Point implements Comparable{

    private int x;
    private int y;

    Point(int x, int mum){
        this.x = x;
        y = mum;
    }

    public int getX(){
        return x;
    }
    public  void setX(int x){
        this.x = x;
    }
    public  void setY(int y){
        this.y = y;
    }
    public int getY(){
        return y;
    }
    public boolean equals(Point b){
        if(this.x == b.getX() && this.y == b.getY())
            return true;
        return false;
    }
    public int compareTo(Object obj)
    {
      Point tmp = (Point)obj;
      if(this.x < tmp.getX())
      {
        /* текущее меньше полученного */
        return -1;
      }
      else if(this.x > tmp.getX())
      {
        /* текущее больше полученного */
        return 1;
      }
      /* текущее равно полученному */
      return 0;
    }

    public String toString(){
        return x+" "+y;
    }

}

public static long sum(long i){
    long k=0;
    while(i>0){
        k+=i%10;
        i/=10;
    }
    return k;
}

public static ArrayList<Integer> list = new ArrayList<Integer>();

public static void REC(String s, int pos, int value){
    if(pos==s.length()){
        list.add(value);

    }
    else{
        if(s.charAt(pos)=='+'){
        REC(s,pos+1,value+1);
    }
    else if(s.charAt(pos)=='-'){
        REC(s,pos+1,value-1);
    }
    else {
        REC(s,pos+1,value+1);
        REC(s,pos+1,value-1);
    }
    }
}

public static void Solve() throws IOException{

 String a= readString();
	String help = readString();
	a+=help.charAt(1);
	a+=help.charAt(0);
	String b = readString();
	help = readString();
	b+=help.charAt(1);
	b+=help.charAt(0);

	char[] mas1, mas2;

	mas1 = new char[3];
	mas2 = new char[3];
	int k,z;
	k=z=0;
	for(int i=0;i<4;i++){
		if(a.charAt(i)!='X'){
			mas1[k]= a.charAt(i);

			k++;
		}
		if(b.charAt(i)!='X'){
			mas2[z] = b.charAt(i);

			z++;
		}
	}
	int x=0;
	for(int i=0;i<3;i++){
		if(mas2[i]==mas1[1]) x=i;
	}

	if(x==0){
		char s = mas2[2];
		for(int i=2;i>0;i--){
			mas2[i] = mas2[i-1];
		}
		mas2[0] = s;
	}
	if(x==2){
		char s = mas2[0];
		for(int i=0;i<2;i++){
			mas2[i] = mas2[i+1];
		}
		mas2[2] = s;
	}

	String ans1, ans2;
	ans1 ="";
	ans2="";
	for(int i=0;i<3;i++){
		ans1+=mas1[i];
		ans2+=mas2[i];
	}

	if(ans1.equals(ans2))
		out.print("YES");
	else out.print("NO");
}

public static void main(String[] args) throws IOException {
init();
Solve();

in.close();
out.close();
}
}

import java.io.*;

public class KROK_taskA {
    public static void main(String[] args)throws IOException{
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String o = "";
        String o2 = "";
        String s1 = in.readLine();
        String s2 = in.readLine();
        s2 = new StringBuffer(s2).reverse().toString();
        String k1 = s1+s2+s1+s2;
        s1 = in.readLine();
        s2 = in.readLine();
        s2 = new StringBuffer(s2).reverse().toString();
        String k2 = s1+s2+s1+s2;
        int i = 0;
        while (k1.charAt(i)!= 'A'){
            i++;
        }
        int s = 0;
        while (s != 3){
            if (k1.charAt(i) != 'X'){
                o += k1.charAt(i);
                i++;
                s++;
            }else{
                i++;
            }
        }
        i = 0;
        while (k2.charAt(i)!= 'A'){
            i++;
        }
        s = 0;
        while (s != 3){
            if (k2.charAt(i) != 'X'){
                o2 += k2.charAt(i);
                i++;
                s++;
            }else{
                i++;
            }
        }
        if (o.compareTo(o2)==0){
            System.out.println("YES");
        }else{
            System.out.println("NO");
        }

    }
}

import java.util.Scanner;

public class AmityAssessment {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String str1 = sc.nextLine() + new StringBuilder(sc.nextLine()).reverse().toString();
		String str2 = sc.nextLine() + new StringBuilder(sc.nextLine()).reverse().toString();
		str1 = str1.replaceAll("X", "");
		str2 = str2.replaceAll("X", "");
		//System.out.println(str1);
		//System.out.println(str2);
		boolean f = false;
		for(int i = 0; i < 3; i++) {
		//	System.out.println(str1);
		//	System.out.println(str2);
			if(str1.equals(str2)) {
				f = true;
				break;
			}
			char c[] = str1.toCharArray();
			str1 = c[1]  + ""+ c[2] + "" + c[0] + "";
		}
		if(f) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}

}

import java.util.*;
import java.io.*;

public class A645
{

	public static void main(String[] args) throws Exception
	{
		Scanner in = new Scanner(System.in);
		String a1 = in.next();
        String a2 = in.next();
        String b1 = in.next();
        String b2 = in.next();

        String s1 = concat(a1, a2);
        String s2 = concat(b1, b2);

        int cnt = 0;
        for (int i = 0; i < s1.length(); i++) {
            if (s1.charAt(i) == s2.charAt(i)) {
                cnt++;
            }
        }
        if (cnt == 0 || cnt == 3) {
            System.out.println("YES");
        }
        else
            System.out.println("NO");

	}

    public static String concat(String s1, String s2) {
        String ans = "";
        for (int i = 0; i < s1.length(); i++) {
            if (s1.charAt(i) != 'X') {
                ans += s1.charAt(i)+"";
            }
        }
        for (int i = s2.length()-1; i >= 0; i--) {
            if (s2.charAt(i) != 'X') {
                ans += s2.charAt(i)+"";
            }
        }
        return ans;
    }
}

import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class A {

    String getString(String[] s){
        if(s[0].charAt(0)=='X'){
            return ""+s[0].charAt(1)+s[1].charAt(1)+s[1].charAt(0);
        }
        if(s[0].charAt(1)=='X'){
            return ""+s[1].charAt(1)+s[1].charAt(0)+s[0].charAt(0);
        }
        if(s[1].charAt(0)=='X')
            return s[0]+s[1].charAt(1);
        return ""+s[1].charAt(0)+s[0];
    }

    void solve() throws IOException {
        String[] s1=new String[2];
        String[] s2=new String[2];
        s1[0]=nextToken();
        s1[1]=nextToken();
        s2[0]=nextToken();
        s2[1]=nextToken();
        String a=getString(s1);
        String b=getString(s2);
        for(int i=0;i<4;i++){
            if(a.equals(b)){
                out.println("YES");
                return;
            }
            b=""+b.charAt(1)+b.charAt(2)+b.charAt(0);
        }
        out.println("NO");
    }

    public static void main(String[] args) throws IOException {
        new A().run();
    }

    void run() throws IOException {
        reader = new BufferedReader(new InputStreamReader(System.in));
//		reader = new BufferedReader(new FileReader("input.txt"));
        tokenizer = null;
        out = new PrintWriter(new OutputStreamWriter(System.out));
//		out = new PrintWriter(new FileWriter("output.txt"));
        solve();
        reader.close();
        out.flush();

    }

    BufferedReader reader;
    StringTokenizer tokenizer;
    PrintWriter out;

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    String nextToken() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }
}

//package com.java.amity.codes;

import java.util.Scanner;

public class Amity {

	public static void main(String [] args) {

		Scanner in = new Scanner(System.in);
		String[] arrBess = new String[4];
		String[] arrElsie = new String[4];
		String bess;
		String newBess;
		String elsie;
		String newElsie;

		for(int i=0; i<2; i++) {
			arrBess[i] = in.next();
		}
		bess = arrBess[0] + arrBess[1].substring(1) + arrBess[1].substring(0,1);

		for(int j=0; j<2; j++) {
			arrElsie[j] = in.next();
			if(arrElsie[j].equals("X")) {
				arrElsie[j] = "";
			}
		}
		elsie = arrElsie[0] + arrElsie[1].substring(1) + arrElsie[1].substring(0,1);

		newBess=bess.replace("X", "");
		newElsie=elsie.replace("X", "");

		if(newBess.substring(0,3).equals(newElsie.substring(0,3))) {
			System.out.print("YES");
		}else {
			newBess = newBess + newBess.substring(0,1);
			newElsie = newElsie + newElsie.substring(0,1);
			if( (newBess.substring(1).equals(newElsie.substring(0,3))) || (newBess.substring(0,3).equals(newElsie.substring(1))) ) {
				System.out.print("YES");
			}else {
				System.out.print("NO");
			}
		}
	}
}

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;

public class P645A {
  InputStream is;
  PrintWriter out;
  String INPUT = "AB\n" +
      "XC\n" +
      "AC\n" +
      "BX\n";

  void solve() {
    String row1 = join(read(ns(), false) + read(ns(), true));
    String row2 = join(read(ns(), false) + read(ns(), true));
    if (row1.equals(row2)) {
      System.out.println("YES");
      return;
    }
    System.out.println("NO");
  }

  private String join(String ns) {
    ns = ns.replaceAll("X", "");
    int index = ns.indexOf('A');
    if (index > 0) {
      ns = ns.substring(index) + ns.substring(0, index);
    }
    return ns;
  }

  private String read(String ns, boolean b) {
    if (b) {
      ns = ns.substring(1) + ns.substring(0, 1);
    }
    return ns;
  }

  public static void main(String[] args) throws Exception {
    new P645A().run();
  }

  void run() throws Exception {
    is = oj ? System.in : new ByteArrayInputStream(INPUT.getBytes());
    out = new PrintWriter(System.out);

    long s = System.currentTimeMillis();
    solve();
    out.flush();
    tr(System.currentTimeMillis() - s + "ms");
  }

  private byte[] inbuf = new byte[1024];
  private int lenbuf = 0, ptrbuf = 0;

  private int readByte() {
    if (lenbuf == -1)
      throw new InputMismatchException();
    if (ptrbuf >= lenbuf) {
      ptrbuf = 0;
      try {
        lenbuf = is.read(inbuf);
      } catch (IOException e) {
        throw new InputMismatchException();
      }
      if (lenbuf <= 0)
        return -1;
    }
    return inbuf[ptrbuf++];
  }

  private boolean isSpaceChar(int c) {
    return !(c >= 33 && c <= 126);
  }

  private int skip() {
    int b;
    while ((b = readByte()) != -1 && isSpaceChar(b))
      ;
    return b;
  }

  private double nd() {
    return Double.parseDouble(ns());
  }

  private char nc() {
    return (char) skip();
  }

  private String ns() {
    int b = skip();
    StringBuilder sb = new StringBuilder();
    while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != ' ')
      sb.appendCodePoint(b);
      b = readByte();
    }
    return sb.toString();
  }

  private char[] ns(int n) {
    char[] buf = new char[n];
    int b = skip(), p = 0;
    while (p < n && !(isSpaceChar(b))) {
      buf[p++] = (char) b;
      b = readByte();
    }
    return n == p ? buf : Arrays.copyOf(buf, p);
  }

  private char[][] nm(int n, int m) {
    char[][] map = new char[n][];
    for (int i = 0; i < n; i++)
      map[i] = ns(m);
    return map;
  }

  private int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private int ni() {
    int num = 0, b;
    boolean minus = false;
    while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
      ;
    if (b == '-') {
      minus = true;
      b = readByte();
    }

    while (true) {
      if (b >= '0' && b <= '9') {
        num = num * 10 + (b - '0');
      } else {
        return minus ? -num : num;
      }
      b = readByte();
    }
  }

  private long nl() {
    long num = 0;
    int b;
    boolean minus = false;
    while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
      ;
    if (b == '-') {
      minus = true;
      b = readByte();
    }

    while (true) {
      if (b >= '0' && b <= '9') {
        num = num * 10 + (b - '0');
      } else {
        return minus ? -num : num;
      }
      b = readByte();
    }
  }

  private boolean oj = System.getProperty("ONLINE_JUDGE") != null;

  private void tr(Object... o) {
    if (!oj)
      System.out.println(Arrays.deepToString(o));
  }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * Created by Kamil Khadiev on 11.08.2015.
 */
public class khadiev_krok_r1_a {
    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        init(in);
        in.close();
        solve();
        PrintWriter out = new PrintWriter(System.out);
        print(out);
        out.close();

    }
    public static int n, a, b, type;
    public static int[][]d;
    public static long ans;
    public static int INF = Integer.MAX_VALUE/2;

    static String s1;
    static String s2;
    private static void init(BufferedReader in) throws IOException {

        s1 = in.readLine().trim() + (new StringBuilder(in.readLine().trim())).reverse().toString();
        s2 = in.readLine().trim() + (new StringBuilder(in.readLine().trim())).reverse().toString();
        s1 = s1.replaceAll("X","");
        s2 = s2.replaceAll("X","");
    }

    private static void solve() {
        ans = 0;
        for (int i = 0; i < 5; i++){
            if (s1.equals(s2)){
                ans = 1;
                break;
            }
            s1 = s1.substring(1) + s1.charAt(0);
        }
    }

    private static void print(PrintWriter out) throws IOException {
        out.print((ans==1) ? "YES" : "NO");
    }
}

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Collections;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

    public static Set<String> fs = new HashSet<>();
    public static Set<String> ss = new HashSet<>();
    public static int[][] v = {
            {0,1},
            {1,3},
            {3,2},
            {2,0}
    };

    public static void frec(String curr, Set<String> s){
        for (int i =0 ;i < v.length; ++ i){
            if (curr.charAt(v[i][0]) == 'X' || curr.charAt(v[i][1]) == 'X'){
                char[] arr = curr.toCharArray();
                char t = arr[v[i][0]];
                arr[v[i][0]] = arr[v[i][1]];
                arr[v[i][1]] = t;
                String n = new String(arr);
                if (!s.contains(n)){
                    s.add(n);
                    frec(new String(arr), s);
                }

            }
        }
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String f =  scanner.next();
        f += scanner.next();
        String s = scanner.next();
        s += scanner.next();
        //BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        frec(f,fs);
        frec(s,ss);
        fs.retainAll(ss);
        if (fs.size() > 0){
            System.out.println("YES");
        }else{
            System.out.println("NO");
        }
    }
}

import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.InputStream;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }
}

class Task {

    public void solve(Scanner in, PrintWriter out) {
        String a = in.next();
        String b = in.next();
        String c = in.next();
        String d = in.next();
        a = a + b.charAt(1) + b.charAt(0);

        c = c + d.charAt(1) + d.charAt(0);
        List<Character> aa = new ArrayList<>();
        List<Character> cc = new ArrayList<>();
        for (int i = 0; i < 4; i++) {
            aa.add(a.charAt(i));
            cc.add(c.charAt(i));
        }

        aa.remove(new Character('X'));
        cc.remove(new Character('X'));

        for (int i = 0; i < 4; i++) {
            if (aa.get(0) == cc.get(0) && aa.get(1) == cc.get(1) && aa.get(2) == cc.get(2)) {
                System.out.println("YES");
                return;
            } else {
                Character temp = aa.get(0);
                Character temp1 = aa.get(1);

                aa.set(0, aa.get(2));
                aa.set(1, temp);
                aa.set(2, temp1);
            }
        }
        System.out.println("NO");

    }

}

class Scanner {
    BufferedReader in;
    StringTokenizer tok;

    public Scanner(InputStream in) {
        this.in = new BufferedReader(new InputStreamReader(in));
        tok = new StringTokenizer("");
    }

    private String tryReadNextLine() {
        try {
            return in.readLine();
        } catch (Exception e) {
            throw new InputMismatchException();
        }
    }

    public String nextToken() {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(next());
        }
        return tok.nextToken();
    }

    public String next() {
        String newLine = tryReadNextLine();
        if (newLine == null)
            throw new InputMismatchException();
        return newLine;
    }

    public int nextInt() {
        return Integer.parseInt(nextToken());
    }
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Set;
import java.io.IOException;
import java.io.Reader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.io.StringReader;
import java.io.BufferedReader;
import java.util.Collections;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Denis Nedelyaev
 */
public class Main {
    public static void main(String[] args) throws Exception {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA(in, out);
        solver.solve(1);
        out.close();
    }

    static class TaskA {
        private final FastScanner in;
        private final PrintWriter out;

        public TaskA(FastScanner in, PrintWriter out) {
            this.in = in;
            this.out = out;
        }

        public void solve(int testNumber) throws IOException {
            String a = in.next() + in.next();
            String b = in.next() + in.next();

            List<String> verts = new ArrayList<>();
            char[] chars = {'A', 'B', 'C', 'X'};
            for (int i1 = 0; i1 < 4; i1++) {
                for (int i2 = 0; i2 < 4; i2++) {
                    for (int i3 = 0; i3 < 4; i3++) {
                        for (int i4 = 0; i4 < 4; i4++) {
                            char c1 = chars[i1];
                            char c2 = chars[i2];
                            char c3 = chars[i3];
                            char c4 = chars[i4];
                            Set<Character> set = new HashSet<>();
                            set.add(c1);
                            set.add(c2);
                            set.add(c3);
                            set.add(c4);
                            if (set.size() == 4) {
                                verts.add("" + c1 + c2 + c3 + c4);
                            }
                        }
                    }
                }
            }

            int n = verts.size();

            boolean[][] canMove = new boolean[n][n];
            for (int i = 0; i < n; i++) {
                nextV:
                for (int j = 0; j < n; j++) {
                    String u = verts.get(i);
                    String v = verts.get(j);
                    for (int s = 0; s < 4; s++) {
                        for (int t = 0; t < 4; t++) {
                            if (canMove(u, v, s, t)) {
                                canMove[i][j] = true;
                                continue nextV;
                            }
                        }
                    }
                }
            }

            for (int k = 0; k < n; k++) {
                for (int i = 0; i < n; i++) {
                    for (int j = 0; j < n; j++) {
                        canMove[i][j] = canMove[i][j] || canMove[i][k] && canMove[k][j];
                    }
                }
            }

            int i = Collections.binarySearch(verts, a);
            int j = Collections.binarySearch(verts, b);

            out.println(canMove[i][j] ? "YES" : "NO");
        }

        boolean canMove(String u, String v, int s, int t) {
            int sx = s % 2;
            int sy = s / 2;
            int tx = t % 2;
            int ty = t / 2;

            if (sx != tx && sy != ty) {
                return false;
            }

            if (u.charAt(s) != 'X' && v.charAt(t) != 'X') {
                return false;
            }

            if (u.charAt(s) != v.charAt(t) || u.charAt(t) != v.charAt(s)) {
                return false;
            }

            for (int i = 0; i < 4; i++) {
                if (i != s && i != t) {
                    if (u.charAt(i) != v.charAt(i)) {
                        return false;
                    }
                }
            }

            return true;
        }

    }

    static class FastScanner {
        private final BufferedReader br;
        private String line;
        private int pos;

        public FastScanner(String s) throws IOException {
            this(new StringReader(s));
        }

        public FastScanner(InputStream is) throws IOException {
            this(new InputStreamReader(is, "UTF-8"));
        }

        public FastScanner(Reader reader) throws IOException {
            this(new BufferedReader(reader));
        }

        public FastScanner(BufferedReader reader) throws IOException {
            br = reader;
            line = br.readLine();
            pos = 0;
        }

        public String next() throws IOException {
            if (!skipWhitespace()) {
                return null;
            }

            int start = pos;

            while (pos < line.length()) {
                char c = line.charAt(pos);

                if (c == ' ' || c == '\t') {
                    break;
                }

                pos++;
            }

            return line.substring(start, pos);
        }

        private boolean skipWhitespace() throws IOException {
            while (line != null) {
                while (pos < line.length()) {
                    char c = line.charAt(pos);

                    if (c != ' ' && c != '\t') {
                        return true;
                    }

                    pos++;
                }

                line = br.readLine();
                pos = 0;
            }

            return false;
        }

    }
}

import java.io.*;
import java.util.Locale;

/**
 * @author master_j
 * @version 0.4.1
 * @since Mar 22, 2015
 */
public class Solution {
    private void solve() throws IOException {
        String s1 = (io.nS() + new StringBuilder(io.nS()).reverse().toString()).replaceAll("X", "");
        String s2 = (io.nS() + new StringBuilder(io.nS()).reverse().toString()).replaceAll("X", "");
        io.wln((s2 + s2).contains(s1) ? "YES" : "NO");
    }//2.2250738585072012e-308

    public static void main(String[] args) throws IOException {
        IO.launchSolution(args);
    }

    Solution(IO io) throws IOException {
        this.io = io;
        solve();
    }

    private final IO io;
}

class IO {
    static final String _localArg = "master_j";
    private static final String _problemName = "";
    private static final IO.Mode _inMode = Mode.STD_;
    private static final IO.Mode _outMode = Mode.STD_;
    private static final boolean _autoFlush = false;

    enum Mode {STD_, _PUT_TXT, PROBNAME_}

    private final StreamTokenizer st;
    private final BufferedReader br;
    private final Reader reader;

    private final PrintWriter pw;
    private final Writer writer;

    static void launchSolution(String[] args) throws IOException {
        boolean local = (args.length == 1 && args[0].equals(IO._localArg));
        IO io = new IO(local);

        long nanoTime = 0;
        if (local) {
            nanoTime -= System.nanoTime();
            io.wln("<output>");
        }

        io.flush();
        new Solution(io);
        io.flush();

        if (local) {
            io.wln("</output>");
            nanoTime += System.nanoTime();
            final long D9 = 1000000000, D6 = 1000000, D3 = 1000;
            if (nanoTime >= D9)
                io.wf("%d.%d seconds\n", nanoTime / D9, nanoTime % D9);
            else if (nanoTime >= D6)
                io.wf("%d.%d millis\n", nanoTime / D6, nanoTime % D6);
            else if (nanoTime >= D3)
                io.wf("%d.%d micros\n", nanoTime / D3, nanoTime % D3);
            else
                io.wf("%d nanos\n", nanoTime);
        }

        io.close();
    }

    IO(boolean local) throws IOException {
        if (_inMode == Mode.PROBNAME_ || _outMode == Mode.PROBNAME_)
            if (_problemName.length() == 0)
                throw new IllegalStateException("You imbecile. Where's my <_problemName>?");

        if (_problemName.length() > 0)
            if (_inMode != Mode.PROBNAME_ && _outMode != Mode.PROBNAME_)
                throw new IllegalStateException("You imbecile. What's the <_problemName> for?");

        Locale.setDefault(Locale.US);

        if (local) {
            reader = new FileReader("input.txt");
            writer = new OutputStreamWriter(System.out);
        } else {
            switch (_inMode) {
                case STD_:
                    reader = new InputStreamReader(System.in);
                    break;
                case PROBNAME_:
                    reader = new FileReader(_problemName + ".in");
                    break;
                case _PUT_TXT:
                    reader = new FileReader("input.txt");
                    break;
                default:
                    throw new NullPointerException("You imbecile. Gimme _inMode.");
            }
            switch (_outMode) {
                case STD_:
                    writer = new OutputStreamWriter(System.out);
                    break;
                case PROBNAME_:
                    writer = new FileWriter(_problemName + ".out");
                    break;
                case _PUT_TXT:
                    writer = new FileWriter("output.txt");
                    break;
                default:
                    throw new NullPointerException("You imbecile. Gimme _outMode.");
            }
        }

        br = new BufferedReader(reader);
        st = new StreamTokenizer(br);

        pw = new PrintWriter(writer, _autoFlush);

        if (local && _autoFlush)
            wln("Note: auto-flush is on.");
    }

    //@formatter:off
    void wln()          {pw.println(); }
    void wln(boolean x) {pw.println(x);}
    void wln(char x)    {pw.println(x);}
    void wln(char x[])  {pw.println(x);}
    void wln(double x)  {pw.println(x);}
    void wln(float x)   {pw.println(x);}
    void wln(int x)     {pw.println(x);}
    void wln(long x)    {pw.println(x);}
    void wln(Object x)  {pw.println(x);}
    void wln(String x)  {pw.println(x);}

    void wf(String f, Object... o) {pw.printf(f, o);}

    void w(boolean x)   {pw.print(x);}
    void w(char x) {pw.print(x);}
    void w(char x[]) {pw.print(x);}
    void w(double x)    {pw.print(x);}
    void w(float x)     {pw.print(x);}
    void w(int x)       {pw.print(x);}
    void w(long x)      {pw.print(x);}
    void w(Object x)    {pw.print(x);}
    void w(String x)    {pw.print(x);}

    int nI() throws IOException {st.nextToken(); return (int)st.nval;}
    double nD() throws IOException {st.nextToken(); return st.nval;}
    float nF() throws IOException {st.nextToken(); return (float)st.nval;}
    long nL() throws IOException   {st.nextToken(); return (long)st.nval;}
    String nS() throws IOException {st.nextToken(); return st.sval;}

    int[] nIa(int n) throws IOException {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nI();
        return a;
    }
    double[] nDa(int n) throws IOException {
        double[] a = new double[n];
        for (int i = 0; i < n; i++)
            a[i] = nD();
        return a;
    }
    String[] nSa(int n) throws IOException {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = nS();
        return a;
    }

    void wc(String x)         {wc(x.toCharArray());}
    void wc(char c1, char c2) {for (char c = c1; c<=c2; c++) wc(c);}
    void wc(char x[])         {for (char c : x) wc(c); }
    void wc(char x)           {st.ordinaryChar(x); st.wordChars(x, x);}

    public boolean eof() {return st.ttype == StreamTokenizer.TT_EOF;}
    public boolean eol() {return st.ttype == StreamTokenizer.TT_EOL;}

    void flush() {pw.flush();}
    void close() throws IOException {reader.close(); br.close(); flush(); pw.close();}
    //@formatter:on
}

import java.util.Scanner;

public class SlidingPuzzle {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		char[][] before = new char[2][2], after = new char[2][2];
		for(int i = 0; i < 4; i++) {
			String in = scan.next();
			for(int j = 0; j < 2; j++){
				if(i < 2) before[i][j] = in.charAt(j);
				else after[i-2][j] = in.charAt(j);
			}
		}
		String pattern = "";
		for(int i = 0; i < 2; i++) for(int j = 0; j < 2; j++) pattern+=i==0?before[i][j]:before[i][1-j];
		String match = "";
		for(int i = 0; i < 2; i++) for(int j = 0; j < 2; j++) match+=i==0?after[i][j]:after[i][1-j];
		pattern = pattern.replaceAll("X", "");
		match = match.replaceAll("X", "");
		int start = -1;
		for(int i = 0; i < 3; i++) if(pattern.charAt(0) == match.charAt(i)) start = i;
		boolean good = false;
		if(pattern.charAt(1) == match.charAt((start+1)%3) && pattern.charAt(2) == match.charAt((start+2)%3)) good = true;
		System.out.println(good?"YES":"NO");
	}

}

//package codeforces.croc2016e;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * Created by macnur on 3/18/16.
 */
public class ProblemA {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        //BufferedReader br = new BufferedReader(new FileReader("in.txt"));
        char[][] b = new char[2][2];
        char[][] l = new char[2][2];

        String line = br.readLine();
        b[0][0] = line.charAt(0);
        b[0][1] = line.charAt(1);
        line = br.readLine();
        b[1][0] = line.charAt(0);
        b[1][1] = line.charAt(1);

        line = br.readLine();
        l[0][0] = line.charAt(0);
        l[0][1] = line.charAt(1);
        line = br.readLine();
        l[1][0] = line.charAt(0);
        l[1][1] = line.charAt(1);

        StringBuilder sb = new StringBuilder();
        for (String ss: getSeq(b).split("X")) {
            sb.append(ss);
        }
        String lhs = sb.toString();
        sb = new StringBuilder();
        for (String ss: getSeq(l).split("X")) {
            sb.append(ss);
        }
        String rhs = sb.toString();

        if (rhs.equals(lhs)) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }

    }

    public static String getSeq(char[][] m) {
        String res;
        if (m[0][0] == 'A') {
            res = "" + m[0][0] + m[0][1] + m[1][1] + m[1][0];
        } else if (m[0][1] == 'A') {
            res = "" + m[0][1] + m[1][1] + m[1][0] + m[0][0];
        } else if (m[1][1] == 'A') {
            res = "" + m[1][1] + m[1][0] + m[0][0] + m[0][1];
        } else {
            res = "" + m[1][0] + m[0][0] + m[0][1] + m[1][1];
        }
        return res;
    }

}

import java.util.*;

import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

import static java.lang.Integer.*;

public class Main {
	public static void main(String[] args) throws Exception{
		InputReader in = new InputReader(System.in);
		PrintWriter out = new PrintWriter(System.out);
		TaskA solver = new TaskA();
		solver.solve(1, in, out);
		out.close();
	}

static class TaskA {
  // GCD && LCM
	 long gcd(long a ,long b){return b == 0 ? a : gcd(b , a % b);}
	 long lcm(long a , long b){return a*(b/gcd(a, b));}

	 // REverse a String
	String rev(String s){
		return new StringBuilder(s).reverse().toString();
	}
	/*          SOLUTION  IS RIGHT HERE     */
	public void solve(int testNumber, InputReader in, PrintWriter out) throws IOException{
		 //BufferedReader  br = new BufferedReader(new InputStreamReader(System.in));
		//  Scanner sc = new Scanner(System.in);
      String s = in.next()+rev(in.next());
	  char[] one = (s+s).toCharArray();
	  s = in.next()+rev(in.next());
	  char[] two = (s+s).toCharArray();
	  String a ="" , b = "";
	  int i = 0;
	  while(one[i] != 'X')i++;
	  i++;
	  for(; i < one.length ; i++){
		  if(one[i] == 'X')break;
		  a += one[i];
	  }

	  i = 0;
	  while(two[i] != 'X')i++;
	  i++;
	  for(; i < two.length ; i++){
		  if(two[i] == 'X')break;
		  b += two[i];
	  }

	  int c = b.indexOf(a.charAt(0));
	  String cs = b.substring(c) + (b.substring(0 , c));
	 // out.println(a+" "+ b + " "+cs);
	  if(a.equals(cs))
		  out.println("YES");
	  else
		  out.println("NO");
  }
}

 // ||||||| INPUT READER ||||||||
 static class InputReader {
	private byte[] buf = new byte[8000];
	private int index;
	private int total;
	private InputStream in;
	BufferedReader br = new  BufferedReader(new InputStreamReader(System.in));
	public InputReader(InputStream stream){
		in = stream;
	}

	public int scan(){
		if(total == -1)
			throw new InputMismatchException();
		if(index >= total){
			index = 0;
			try{
			total = in.read(buf);
			}catch(IOException e){
			   throw new InputMismatchException();
			}
			if(total <= 0)
				return -1;
		}
		return buf[index++];
	}
	public long scanlong(){
		long integer = 0;
		int n = scan();
		while(isWhiteSpace(n))
			n = scan();
		int neg = 1;
		if(n == '-'){
			neg = -1;
			n = scan();
		}
		while(!isWhiteSpace(n)){
			if(n >= '0' && n <= '9'){
				integer *= 10;
				integer += n - '0';
				n = scan();
			}
			else throw new InputMismatchException();
		}
		return neg*integer;
	}

	private int scanInt() {
		int integer = 0;
		int n = scan();
		while(isWhiteSpace(n))
			n = scan();
		int neg = 1;
		if(n == '-'){
			neg = -1;
			n = scan();
		}
		while(!isWhiteSpace(n)){
			if(n >= '0' && n <= '9'){
				integer *= 10;
				integer += n - '0';
				n = scan();
			}
			else throw new InputMismatchException();
		}
		return neg*integer;
	}

	public double scandouble(){
		double doubll = 0;
		int n = scan();
		int neg = 1;
		while(isWhiteSpace(n))
			n = scan();
		if(n == '-'){
			neg = -1;
			n = scan();
		}
		while(!isWhiteSpace(n) && n != '.'){
			if(n >= '0' && n <= '9'){
				doubll *= 10;
				doubll += n - '0';
				n = scan();
			}
		}
		if(n == '.'){
			n = scan();
			double temp = 1;
			while(!isWhiteSpace(n)){
				if(n >= '0' && n <= '9'){
					temp /= 10;
					doubll += (n - '0')*temp;
					n = scan();
				}
			}
		}
		return neg*doubll;
	}

	private float scanfloat() {
		float doubll = 0;
		int n = scan();
		int neg = 1;
		while(isWhiteSpace(n))
			n = scan();
		if(n == '-'){
			neg = -1;
			n = scan();
		}
		while(!isWhiteSpace(n) && n != '.'){
			if(n >= '0' && n <= '9'){
				doubll *= 10;
				doubll += n - '0';
				n = scan();
			}
		}
		if(n == '.'){
			n = scan();
			double temp = 1;
			while(!isWhiteSpace(n)){
				if(n >= '0' && n <= '9'){
					temp /= 10;
					doubll += (n - '0')*temp;
					n = scan();
				}
			}
		}
		return neg*doubll;
	}
	public String scanstring(){
		StringBuilder sb = new StringBuilder();
		int n = scan();
		while(isWhiteSpace(n))
			n = scan();
		while(!isWhiteSpace(n)){
			sb.append((char)n);
			n = scan();
		}
		return sb.toString();
	}

	public String scan_nextLine() {
        int n = scan();
        while (isWhiteSpace(n))
            n = scan();
        StringBuilder res = new StringBuilder();
        do {
            res.appendCodePoint(n);
            n = scan();
        } while (!isEndOfLine(n));
        return res.toString();
    }
	public boolean isWhiteSpace(int n){
		if(n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1)
			return true;
		return false;
	}

	private boolean isEndOfLine(int c) {
        return c == '\n' || c == '\r' || c == -1;
    }
/// Input module

	public int nextInt(){
	  return scanInt();
	}

	public long nextLong(){
		  return  scanlong();
		}

	public double nextDouble(){
		  return  scandouble();
		}

	public float nextFloat(){
		  return scanfloat();
		}

	public String next(){
		return scanstring();
	}

	public String nextLine() throws IOException{
		return scan_nextLine();
	}

	public int[] readIntArray(int size)  {
        int[] array = new int[size];
        for (int i = 0; i < size; i++) {
            array[i] = nextInt();
        }
        return array;
    }
}

}

import java.io.*;
import java.lang.reflect.Array;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;

public class Task3 {

    public static void main(String[] args) throws IOException {

        new Task3().solve();

    }

    //ArrayList<Integer>[] g;

    int mod = 1000000007;

    PrintWriter out;

    int n;
    int m;

    long inf = Long.MAX_VALUE;

    //int[][] g = new int[110][110];

    int max = 0;

    long base = (1L << 63);

    void solve() throws IOException {

        //Reader in = new Reader("in.txt");
        //out = new PrintWriter( new BufferedWriter(new FileWriter("output.txt")) );
        Reader in = new Reader();
        PrintWriter out = new PrintWriter( new BufferedWriter(new OutputStreamWriter(System.out)) );

        //BufferedReader br = new BufferedReader( new FileReader("in.txt") );
        //BufferedReader br = new BufferedReader( new InputStreamReader( System.in ) );

        char[][] a = new char[4][4];
        char[][] b = new char[4][4];

        String s1 = in.next();
        a[0][0] = s1.charAt(0);
        a[0][1] = s1.charAt(1);

        s1 = in.next();
        a[1][0] = s1.charAt(0);
        a[1][1] = s1.charAt(1);

        String s2 = in.next();
        b[0][0] = s2.charAt(0);
        b[0][1] = s2.charAt(1);

        s2 = in.next();
        b[1][0] = s2.charAt(0);
        b[1][1] = s2.charAt(1);

        s1 = ""+a[0][0]+a[0][1]+a[1][1]+a[1][0];
        s2 = ""+b[0][0]+b[0][1]+b[1][1]+b[1][0];

        String rs1 = "";

        for (char ch : s1.toCharArray())
            if (ch != 'X')
                rs1 += ch;

        String rs2 = "";

        for (char ch : s2.toCharArray())
            if (ch != 'X')
                rs2 += ch;

        boolean ok = false;

        //System.out.println(s1+" "+s2);

        for (int i = 0; i < 4; i++) {

            int cnt = 0;

            for (int j = 0; j < 3; j++) {

                int pos = (j+i)%3;

                if (rs1.charAt(j) == rs2.charAt(pos)) {
                    cnt++;
                }
            }

            if (cnt == 3) {
                System.out.println("YES");
                return;
            }

        }

        System.out.println("NO");

        out.flush();
        out.close();
    }

    long gcd(long a, long b) {

        if (b == 0)
            return a;

        return gcd(b, a%b);

    }

    class Item {

        int a;
        int b;
        int c;

        Item(int a, int b, int c) {
            this.a = a;
            this.b = b;
            this.c = c;
        }

    }

    class Pair implements Comparable<Pair>{

        int a;
        int b;
        int i;

        Pair(int a, int b) {

            this.a = a;
            this.b = b;
        }

        public int compareTo(Pair p) {

            if (a > p.a)
                return 1;

            if (a < p.a)
                return -1;

            if (b > p.b)
                return 1;

            if (b < p.b)
                return -1;

            return 0;
        }

        //		@Override
        //		public boolean equals(Object o) {
        //			Pair p = (Pair) o;
        //			return a == p.a && b == p.b;
        //		}
        //
        //		@Override
        //		public int hashCode() {
        //			return Integer.valueOf(a).hashCode() + Integer.valueOf(b).hashCode();
        //		}

    }

    class Reader {

        BufferedReader  br;
        StringTokenizer tok;

        Reader(String file) throws IOException {
            br = new BufferedReader( new FileReader(file) );
        }

        Reader() throws IOException {
            br = new BufferedReader( new InputStreamReader(System.in) );
        }

        String next() throws IOException {

            while (tok == null || !tok.hasMoreElements())
                tok = new StringTokenizer(br.readLine());
            return tok.nextToken();
        }

        int nextInt() throws NumberFormatException, IOException {
            return Integer.valueOf(next());
        }

        long nextLong() throws NumberFormatException, IOException {
            return Long.valueOf(next());
        }

        double nextDouble() throws NumberFormatException, IOException {
            return Double.valueOf(next());
        }

        String nextLine() throws IOException {
            return br.readLine();
        }

    }

}

import java.util.*;
import java.io.*;
public class SlidingPuzzles
{
   public static void main(String[] args)
   {
      Scanner sc = new Scanner(System.in);
      String intop = sc.nextLine();
      String inbot = sc.nextLine();
      String outtop = sc.nextLine();
      String outbot = sc.nextLine();
      boolean fax = isRot(intop+inbot,outtop+outbot);
      if(fax)
         System.out.println("YES");
      else
         System.out.println("NO");
   }
   public static boolean isRot(String in, String out)
   {
      in = in.substring(0,2)+in.substring(3,4)+in.substring(2,3);
      out = out.substring(0,2)+out.substring(3,4)+out.substring(2,3);
      String finalin = "";
      for(int i=0;i<in.length();i++)
      {
         String temp = in.substring(i,i+1);
         if(!temp.equals("X"))
            finalin+=temp;
      }
      String finalout = "";
      for(int i=0;i<out.length();i++)
      {
         String temp = out.substring(i,i+1);
         if(!temp.equals("X"))
            finalout+=temp;
      }
      return (finalin+finalin).contains(finalout);
   }
}

import java.util.Scanner;

public class AmityAssessment {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String line1 = sc.nextLine();
		String line2 = sc.nextLine();
		String s1 = "";
		if (line1.charAt(0) != 'X') {
			s1 = s1.concat(String.valueOf(line1.charAt(0)));
		}
		if (line1.charAt(1) != 'X') {
			s1 = s1.concat(String.valueOf(line1.charAt(1)));
		}
		if (line2.charAt(1) != 'X') {
			s1 = s1.concat(String.valueOf(line2.charAt(1)));
		}
		if (line2.charAt(0) != 'X') {
			s1 = s1.concat(String.valueOf(line2.charAt(0)));
		}
		while (s1.charAt(0) != 'A') {
			char c = s1.charAt(0);
			s1 = s1.substring(1).concat(String.valueOf(c));
		}

		String line3 = sc.nextLine();
		String line4 = sc.nextLine();
		String s2 = "";
		if (line3.charAt(0) != 'X') {
			s2 = s2.concat(String.valueOf(line3.charAt(0)));
		}
		if (line3.charAt(1) != 'X') {
			s2 = s2.concat(String.valueOf(line3.charAt(1)));
		}
		if (line4.charAt(1) != 'X') {
			s2 = s2.concat(String.valueOf(line4.charAt(1)));
		}
		if (line4.charAt(0) != 'X') {
			s2 = s2.concat(String.valueOf(line4.charAt(0)));
		}
		while (s2.charAt(0) != 'A') {
			char c = s2.charAt(0);
			s2 = s2.substring(1).concat(String.valueOf(c));
		}

		if (s1.equals(s2)) {
			System.out.println("YES");
		}
		else {
			System.out.println("NO");
		}
	}

}

import java.util.Scanner;

public class aaa{
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);

		char[] a = new char[4];
		char[] b = new char[4];

		String str="";
		String str2="";
		for(int i=0; i<4; i++){
			str2+=scn.next();
			if(i==1){
				str=str2;
				str2="";
			}
		}
		str = str.substring(0,2)+str.substring(3,4)+str.substring(2,3);
		str2 = str2.substring(0,2)+str2.substring(3,4)+str2.substring(2,3);
		if(isSame(str.replace("X", ""),str2.replace("X", "")))
			System.out.println("YES");
		else
			System.out.println("NO");
	}
	static boolean isSame(String s1, String s2){
		int t=0;
		int stt = s2.indexOf(s1.charAt(0));
		String tmp = "";
		if(stt!=0)
			tmp = s2.substring(stt,3) + s2.substring(0,stt);
		else tmp = s2;
		//System.out.println("1. "+tmp);
		if(tmp.equals(s1))
			return true;
		return false;
		/*if(stt!=2){
			tmp = s2.substring(stt+1,3) + s2.substring(0,stt+1);
		}
		else tmp = s2;
		tmp = new StringBuilder(tmp).reverse().toString();
		System.out.println("2. "+tmp);
		if(tmp.equals(s1))
			return true;
		else return false;*/
	}
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Скромная Няша Стесняша Блять; Зверь нахуй
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        char[][] f(InputReader in) {
            char[][] a = new char[2][];
            a[0] = in.readString().toCharArray();
            a[1] = in.readString().toCharArray();

            while (a[0][0] != 'A') {
                char t = a[0][0];
                a[0][0] = a[1][0];
                a[1][0] = a[1][1];
                a[1][1] = a[0][1];
                a[0][1] = t;
            }

            if (a[0][1] == 'X') {
                char t = a[0][1];
                a[0][1] = a[1][1];
                a[1][1] = t;
            }

            if (a[1][0] == 'X') {
                char t = a[1][0];
                a[1][0] = a[1][1];
                a[1][1] = t;
            }

            return a;
        }

        public void solve(int testNumber, InputReader in, OutputWriter out) {
            char[][] a = f(in), b = f(in);

            for (int i = 0; i < 2; i++) {
                for (int j = 0; j < 2; j++) {
                    if (a[i][j] != b[i][j]) {
                        out.printLine("NO");
                        return;
                    }
                }
            }
            out.printLine("YES");
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public String readString() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            StringBuilder res = new StringBuilder();
            do {
                if (Character.isValidCodePoint(c)) {
                    res.appendCodePoint(c);
                }
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void print(Object... objects) {
            for (int i = 0; i < objects.length; i++) {
                if (i != 0) {
                    writer.print(' ');
                }
                writer.print(objects[i]);
            }
        }

        public void printLine(Object... objects) {
            print(objects);
            writer.println();
        }

        public void close() {
            writer.close();
        }

    }
}

import java.io.*;
import java.util.*;

import static java.lang.Math.*;

public class Main {
    FastScanner in;
    PrintWriter out;

    static final String FILE = "";

    TreeSet<String> set = new TreeSet<>();
    TreeSet<String> set2 = new TreeSet<>();
    boolean can = false;

    void calc(String s) {
        int x = s.indexOf('X');
        if (set.contains(s))
            return;
        set.add(s);

        char tmp;

        if (x == 0) {
            StringBuffer buffer1 = new StringBuffer(s);
            tmp = s.charAt(1);
            buffer1.setCharAt(x, tmp);
            buffer1.setCharAt(1, 'X');
            calc(buffer1.toString());

            StringBuffer buffer2 = new StringBuffer(s);
            tmp = s.charAt(2);
            buffer2.setCharAt(x, tmp);
            buffer2.setCharAt(2, 'X');
            calc(buffer2.toString());
        } else if (x == 1) {
            StringBuffer buffer1 = new StringBuffer(s);
            tmp = s.charAt(0);
            buffer1.setCharAt(x, tmp);
            buffer1.setCharAt(0, 'X');
            calc(buffer1.toString());

            StringBuffer buffer2 = new StringBuffer(s);
            tmp = s.charAt(3);
            buffer2.setCharAt(x, tmp);
            buffer2.setCharAt(3, 'X');
            calc(buffer2.toString());
        } else if (x == 2) {
            StringBuffer buffer1 = new StringBuffer(s);
            tmp = s.charAt(0);
            buffer1.setCharAt(x, tmp);
            buffer1.setCharAt(0, 'X');
            calc(buffer1.toString());

            StringBuffer buffer2 = new StringBuffer(s);
            tmp = s.charAt(3);
            buffer2.setCharAt(x, tmp);
            buffer2.setCharAt(3, 'X');
            calc(buffer2.toString());
        } else if (x == 3) {
            StringBuffer buffer1 = new StringBuffer(s);
            tmp = s.charAt(1);
            buffer1.setCharAt(x, tmp);
            buffer1.setCharAt(1, 'X');
            calc(buffer1.toString());

            StringBuffer buffer2 = new StringBuffer(s);
            tmp = s.charAt(2);
            buffer2.setCharAt(x, tmp);
            buffer2.setCharAt(2, 'X');
            calc(buffer2.toString());
        }
    }

    void find(String s) {
        if (can)
            return;
        int x = s.indexOf('X');
        if (set.contains(s)) {
            can = true;
            return;
        }
        if (set2.contains(s))
            return;
        set2.add(s);

        char tmp;

        if (x == 0) {
            StringBuffer buffer1 = new StringBuffer(s);
            tmp = s.charAt(1);
            buffer1.setCharAt(x, tmp);
            buffer1.setCharAt(1, 'X');
            find(buffer1.toString());

            StringBuffer buffer2 = new StringBuffer(s);
            tmp = s.charAt(2);
            buffer2.setCharAt(x, tmp);
            buffer2.setCharAt(2, 'X');
            find(buffer2.toString());
        } else if (x == 1) {
            StringBuffer buffer1 = new StringBuffer(s);
            tmp = s.charAt(0);
            buffer1.setCharAt(x, tmp);
            buffer1.setCharAt(0, 'X');
            find(buffer1.toString());

            StringBuffer buffer2 = new StringBuffer(s);
            tmp = s.charAt(3);
            buffer2.setCharAt(x, tmp);
            buffer2.setCharAt(3, 'X');
            find(buffer2.toString());
        } else if (x == 2) {
            StringBuffer buffer1 = new StringBuffer(s);
            tmp = s.charAt(0);
            buffer1.setCharAt(x, tmp);
            buffer1.setCharAt(0, 'X');
            find(buffer1.toString());

            StringBuffer buffer2 = new StringBuffer(s);
            tmp = s.charAt(3);
            buffer2.setCharAt(x, tmp);
            buffer2.setCharAt(3, 'X');
            find(buffer2.toString());
        } else if (x == 3) {
            StringBuffer buffer1 = new StringBuffer(s);
            tmp = s.charAt(1);
            buffer1.setCharAt(x, tmp);
            buffer1.setCharAt(1, 'X');
            find(buffer1.toString());

            StringBuffer buffer2 = new StringBuffer(s);
            tmp = s.charAt(2);
            buffer2.setCharAt(x, tmp);
            buffer2.setCharAt(2, 'X');
            find(buffer2.toString());
        }
    }

    public void solve() {
        String a = in.next() + in.next();
        String b = in.next() + in.next();
        calc(a);
        find(b);

        if (can)
            out.println("YES");
        else
            out.println("NO");
    }

    public void run() {
        if (FILE.equals("")) {
            in = new FastScanner(System.in);
            out = new PrintWriter(System.out);
        } else {
            try {
                in = new FastScanner(new FileInputStream(FILE +
                        ".in"));
                out = new PrintWriter(new FileOutputStream(FILE +
                        ".out"));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }
        solve();
        out.close();
    }

    public static void main(String[] args) {
        (new Main()).run();
    }

    class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(InputStream is) {
            br = new BufferedReader(new InputStreamReader(is));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public String nextLine() {
            st = null;
            try {
                return br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
                return "";
            }
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public float nextFloat() {
            return Float.parseFloat(next());
        }
    }

    class Pair<A extends Comparable<A>, B extends Comparable<B>>
            implements Comparable<Pair<A, B>> {
        public A a;
        public B b;

        public Pair(A a, B b) {
            this.a = a;
            this.b = b;
        }

        @Override
        public int compareTo(Pair<A, B> o) {
            if (o == null || o.getClass() != getClass())
                return 1;
            int cmp = a.compareTo(o.a);
            if (cmp == 0)
                return b.compareTo(o.b);
            return cmp;
        }

        @Override
        public boolean equals(Object o) {
            if (this == o) return true;
            if (o == null || getClass() != o.getClass()) return false;

            Pair<?, ?> pair = (Pair<?, ?>) o;

            if (a != null ? !a.equals(pair.a) : pair.a != null) return
                    false;
            return !(b != null ? !b.equals(pair.b) : pair.b != null);
        }
    }

    class PairInt extends Pair<Integer, Integer> {
        public PairInt(Integer u, Integer v) {
            super(u, v);
        }
    }

    class PairLong extends Pair<Long, Long> {
        public PairLong(Long u, Long v) {
            super(u, v);
        }
    }

}

import java.util.Scanner;

public class Ao {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);

        String first = input.nextLine();
        String buf = input.nextLine();
        first += buf.charAt(1);
        first += buf.charAt(0);

        String second = input.nextLine();
        buf = input.nextLine();
        second += buf.charAt(1);
        second += buf.charAt(0);

        first = first.replace("X", "");
        second = second.replace("X", "");

        char c = first.charAt(0);
        while (c != second.charAt(0)) {
            second = second.substring(1) + second.charAt(0);
        }
        if (first.equals(second)) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class A {

	static StringTokenizer st;
	static BufferedReader br;
	static PrintWriter pw;
	public static void main(String[] args) throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
		char[][]a = new char[5][3];
		for (int i = 1; i <= 4; i++) {
			String s = next();
			a[i][1] = s.charAt(0);
			a[i][2] = s.charAt(1);
		}
		String s1 = "";
		if (a[1][1] != 'X')
			s1 += a[1][1];
		if (a[1][2] != 'X')
			s1 += a[1][2];
		if (a[2][2] != 'X')
			s1 += a[2][2];
		if (a[2][1] != 'X')
			s1 += a[2][1];
		String s2 = "";
		if (a[3][1] != 'X')
			s2 += a[3][1];
		if (a[3][2] != 'X')
			s2 += a[3][2];
		if (a[4][2] != 'X')
			s2 += a[4][2];
		if (a[4][1] != 'X')
			s2 += a[4][1];
		for (int i = 0; i < 3; i++) {
			if (s1.equals(s2)) {
				System.out.println("YES");
				return;
			}
			s1 = s1.substring(1)+s1.charAt(0);
		}
		System.out.println("NO");
		pw.close();
	}
	private static int nextInt() throws IOException {
		return Integer.parseInt(next());
	}
	private static long nextLong() throws IOException {
		return Long.parseLong(next());
	}
	private static double nextDouble() throws IOException {
		return Double.parseDouble(next());
	}
	private static String next() throws IOException {
		while (st==null || !st.hasMoreTokens())
			st = new StringTokenizer(br.readLine());
		return st.nextToken();
	}
}

import java.io.*;
import java.util.*;

public class A {
	void run() {
		String s = readAndCanonize();
		String t = readAndCanonize();
		System.out.println(s.equals(t) ? "YES" : "NO");
	}

	String readAndCanonize() {
		String s = in.next();
		String t = in.next();
		s = s + t.charAt(1) + t.charAt(0);
		s = s.replaceAll("X", "");
		s = s + s;
		int i = s.indexOf('A');
		s = s.substring(i, i + 3);
		return s;
	}

	static MyScanner in;
	static PrintWriter out;

	public static void main(String[] args) throws IOException {
		boolean stdStreams = true;
		String fileName = A.class.getSimpleName().replaceFirst("_.*", "").toLowerCase();
		String inputFileName = fileName + ".in";
		String outputFileName = fileName + ".out";

		Locale.setDefault(Locale.US);
		BufferedReader br;
		if (stdStreams) {
			br = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
		} else {
			br = new BufferedReader(new FileReader(inputFileName));
			out = new PrintWriter(outputFileName);
		}
		in = new MyScanner(br);
		int tests = 1;//in.nextInt();
		for (int test = 0; test < tests; test++) {
			new A().run();
		}
		br.close();
		out.close();
	}

	static class MyScanner {
		BufferedReader br;
		StringTokenizer st;

		MyScanner(BufferedReader br) {
			this.br = br;
		}

		void findToken() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
		}

		String next() {
			findToken();
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}
	}
}

import java.io.*;
import java.util.*;

public class A {
	FastScanner in;
	PrintWriter out;

	String rev(String s) {
		StringBuffer sb = new StringBuffer(s);
		return sb.reverse().toString();
	}

	String del(String s) {
		StringBuffer sb = new StringBuffer();
		for (int i = 0; i < s.length(); i++) {
			if (s.charAt(i) != 'X') {
				sb.append(s.charAt(i));
			}
		}
		return sb.toString();
	}

	void solve() {
		char[] c;
		char[] t;
		c = del(in.next() + rev(in.next())).toCharArray();
		t = del(in.next() + rev(in.next())).toCharArray();
		for (int i = 0; i < 3; i++) {
			boolean ok = true;
			for (int j = 0; j < 3; j++) {
				if (c[j] != t[(i + j) % 3]) {
					ok = false;
				}
			}
			if (ok) {
				out.println("YES");
				return;
			}
		}
		out.println("NO");
	}

	void run() {
		in = new FastScanner();
		out = new PrintWriter(System.out);

		solve();

		out.close();
	}

	class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		FastScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		FastScanner(File f) {
			try {
				br = new BufferedReader(new FileReader(f));
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}
	}

	public static void main(String[] args) {
		new A().run();
	}
}

import java.util.ArrayList;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.StringTokenizer;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		Reader in = new Reader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskA solver = new TaskA();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskA {
    String read(Reader in) {
        String a = in.nextLine();
        String b = in.nextLine();
        return (a + b.charAt(1) + b.charAt(0)).replace("X", "");
    }
    public void solve(int testNumber, Reader in, PrintWriter out) {
        String a = read(in);
        String b = read(in);
        boolean f = false;
        for (int i = 0; i < 3; i++) {
            String c = b.substring(i) + b.substring(0, i);
            if (a.equals(c)) f = true;
        }
        out.println(f? "YES" : "NO");
    }
}

class Reader {
    private BufferedReader in;

    public Reader(InputStream is) {
        in = new BufferedReader(new InputStreamReader(is));
    }

    public String nextLine() {
        try {
            return in.readLine();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

}

import java.util.*;
import java.math.*;
import java.io.*;
public final class ccnov1
{
	public static void main(String args [])	throws IOException
	{
		BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw=new PrintWriter(System.out, true);
		String p1[][]=new String [2][2];
		String p2[][]=new String [2][2];
		String p3[][]=new String [2][2];
		String str[]=in.readLine().split("");
		String str2[]=in.readLine().split("");
		String str1[]=in.readLine().split("");
		String str3[]=in.readLine().split("");
		int a=0,b=0,c=0,d=0;
		//String a="",b="";
		for(int i=0; i<2; i++)
		{

			for(int j=0; j<2; j++)
			{
				if(i==0)
				{p1[i][j]=(str[j]);p2[i][j]=(str1[j]);}
				else
				{p1[i][j]=(str2[j]);p2[i][j]=(str3[j]);}
				if(p1[i][j].equals("A"))
				{a=i;b=j;}
				if(p2[i][j].equals("A"))
				{c=i;d=j;}
			}
		}
		String use=comb("",a,b,0,p1);
		String use2=comb("",c,d,0,p2);
		if(use.equalsIgnoreCase(use2))
		{pw.println("YES");}
		else
		{pw.println("NO");}
	}
	public static String comb(String ret,int i, int j, int n, String p1[][])
	{
		if(n==4)return ret;
		if(i==0 && j==0)
		{
			if(p1[i][j].equals("X"))ret=comb(ret,0,1,n+1,p1);
			else ret=comb(ret+p1[i][j],0,1,n+1,p1);
			//ret=ret+p1[i][j];
			return ret;
		}
		if(i==0 && j==1)
		{
			if(p1[i][j].equals("X"))ret=comb(ret,1,1,n+1,p1);
			else ret=comb(ret+p1[i][j],1,1,n+1,p1);
			//ret=ret+p1[i][j];
			return ret;
		}
		if(i==1 && j==1)
		{
			if(p1[i][j].equals("X"))ret=comb(ret,1,0,n+1,p1);
			else ret=comb(ret+p1[i][j],1,0,n+1,p1);
			//ret=ret+p1[i][j];
			return ret;
		}
		if(i==1 && j==0)
		{
			if(p1[i][j].equals("X"))ret=comb(ret,0,0,n+1,p1);
			else ret=comb(ret+p1[i][j],0,0,n+1,p1);
			//ret=ret+p1[i][j];
			return ret;
		}
	return null;
	}
}

/* Author LAVLESH */
import java.util.*;
import java.io.*;
import java.math.BigInteger;
public class solution {
	static BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
	static StringTokenizer st=new StringTokenizer("");

	  static public String next() {
	        while (st == null || !st.hasMoreTokens()) {
	            try {
	                st = new StringTokenizer(br.readLine());
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }
	        return st.nextToken();
	    }
	/*static boolean isPalindrome(char[]a){
		for(int i=0,j=a.length-1;i<a.length;i++,j--)
			if(a[i]!=a[j])return false;
		return true;

	}*/
  //  static int gcd(int a,int b){return b==0?a:gcd(b,a%b);}

	/*  public static int lcm(int a,int b, int c){
        return lcm(lcm(a,b),c);
    }

    public static int lcm(int a, int b){
        return a*b/gcd(a,b);
    }*/
    //static long max(long a,long b){return a>b?a:b;}
	//static int min(int a,int b){return a>=b?b:a;}
	//static int mod=(int)1e9+7;

	/*static boolean isprime[]=new boolean[100015];
	  static void sieve(){
		Arrays.fill(isprime,true);
		boolean visited[]=new boolean[100015];
		isprime[0]=false;
		isprime[1]=false;
		for(int i=2;i*i<=100015;i++){
			visited[i]=true;
			for(int j=i*i;j<100015;j+=i){
				if(!visited[j]){
					visited[j]=true;
					isprime[j]=false;
				}
			}
		}
	}*/
	/*static int[] nextArray(int n,int x,int y){
		int []a=new int[n];
		for(int i=x;i<y;i++)
			a[i]=Integer.parseInt(next());
		return a;
	}*/
	/*static void ArrayPrint(int[]a){
		for(int i=0;i<a.length;i++)
			System.out.print(a[i]+" ");
		System.out.println();
	}*/

	  public static void main(String[]args)throws IOException{
        PrintWriter op =new PrintWriter(System.out);
	    StringBuilder sb=new StringBuilder();
	    String s=(next()+sb.append(next()).reverse());
	    sb=new StringBuilder(s);s=sb.append(s).toString();
	    String s1=(next()+sb.append(next()).reverse());
	    StringBuilder sb1=new StringBuilder();
	    StringBuilder sb2=new StringBuilder();
	    for(int i=0;i<4;i++){
	    	if(s1.charAt(i)!='X')sb1.append(s1.charAt(i));
	    }
	   // op.println(sb1);
	    int x=0;
	    while(s.charAt(x)!=sb1.charAt(0))x++;
	    //op.println(sb2.length());
	    while(sb2.length()!=3){
	    	if(s.charAt(x)!='X')sb2.append(s.charAt(x));
	    	x++;
	    }
	    //op.println(sb2);
	    if(sb1.toString().equals(sb2.toString()))op.println("YES");
	    else op.println("NO");
         op.close();
	}
}

import java.io.*;
import java.util.StringTokenizer;

public class Main {

    static MyScanner   in;
    static PrintWriter out;
//    static Timer timer = new Timer();

    public static void main(String[] args) throws IOException {
        in = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out), true);

        String a = read(), b = read();

        for (int i = 0; i < 3; i++) {
            if (a.equals(b)) {
                out.println("YES");
                return;
            }
            a = shift(a);
        }

        out.println("NO");
    }

    static String shift(String s) {
        String a = s.substring(1);
        a += s.charAt(0);

        return a;
    }

    static String read() throws IOException {
        String a = "";

        char[] s = in.next().toCharArray();
        if (s[0] != 'X')
            a += s[0];
        if (s[1] != 'X')
            a += s[1];

        s = in.next().toCharArray();
        if (s[1] != 'X')
            a += s[1];
        if (s[0] != 'X')
            a += s[0];

        return a;
    }

}

class MyScanner {

    private final BufferedReader  br;
    private       StringTokenizer st;
    private       String          last;

    public MyScanner() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    public MyScanner(String path) throws IOException {
        br = new BufferedReader(new FileReader(path));
    }

    public MyScanner(String path, String decoder) throws IOException {
        br = new BufferedReader(new InputStreamReader(new FileInputStream(path), decoder));
    }

    String next() throws IOException {
        while (st == null || !st.hasMoreElements())
            st = new StringTokenizer(br.readLine());
        last = null;
        return st.nextToken();
    }

    String nextLine() throws IOException {
        st = null;
        return (last == null) ? br.readLine() : last;
    }

    boolean hasNext() {
        if (st != null && st.hasMoreElements())
            return true;

        try {
            while (st == null || !st.hasMoreElements()) {
                last = br.readLine();
                st = new StringTokenizer(last);
            }
        }
        catch (Exception e) {
            return false;
        }

        return true;
    }

    String[] nextStrings(int n) throws IOException {
        String[] arr = new String[n];
        for (int i = 0; i < n; i++)
            arr[i] = next();
        return arr;
    }

    String[] nextLines(int n) throws IOException {
        String[] arr = new String[n];
        for (int i = 0; i < n; i++)
            arr[i] = nextLine();
        return arr;
    }

    int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    int[] nextInts(int n) throws IOException {
        int[] arr = new int[n];
        for (int i = 0; i < n; i++)
            arr[i] = nextInt();
        return arr;
    }

    Integer[] nextIntegers(int n) throws IOException {
        Integer[] arr = new Integer[n];
        for (int i = 0; i < n; i++)
            arr[i] = nextInt();
        return arr;
    }

    int[][] next2Ints(int n, int m) throws IOException {
        int[][] arr = new int[n][m];
        for (int i = 0; i < n; i++)
            for (int j = 0; j < m; j++)
                arr[i][j] = nextInt();
        return arr;
    }

    long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    long[] nextLongs(int n) throws IOException {
        long[] arr = new long[n];
        for (int i = 0; i < n; i++)
            arr[i] = nextLong();
        return arr;
    }

    long[][] next2Longs(int n, int m) throws IOException {
        long[][] arr = new long[n][m];
        for (int i = 0; i < n; i++)
            for (int j = 0; j < m; j++)
                arr[i][j] = nextLong();
        return arr;
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(next().replace(',', '.'));
    }

    double[] nextDoubles(int size) throws IOException {
        double[] arr = new double[size];
        for (int i = 0; i < size; i++)
            arr[i] = nextDouble();
        return arr;
    }

    boolean nextBool() throws IOException {
        String s = next();
        if (s.equalsIgnoreCase("true") || s.equals("1"))
            return true;

        if (s.equalsIgnoreCase("false") || s.equals("0"))
            return false;

        throw new IOException("Boolean expected, String found!");
    }
}

import java.io.*;
import java.util.InputMismatchException;

public class CrocA {
    private static InputReader in = new InputReader(System.in);
    private static OutputWriter out = new OutputWriter(System.out);

    private static void solve() throws Exception {
        String l1 = in.readString();
        String l2 = in.readString();
        String l3 = in.readString();
        String l4 = in.readString();

        String s1 = l1+l2;
        String s2 = l3+l4;
        char[] a = new char[4];
        char[] b = new char[4];
        int index = 0;
        for(int i=0; i<4; ++i){

            a[i] = s1.charAt(i);
            if(a[i]=='X'){
                index = i;
            }
        }
        if(index==1){
            a[1] = a[0];
            a[0] = 'X';
        }
        if(index==2){
            a[2] = a[0];
            a[0] = 'X';
        }
        if(index==3){
            a[3] = a[1];
            a[1] = a[0];
            a[0] = 'X';
        }
        char temp = a[2];
        a[2] = a[3];
        a[3] = temp;

        for(int i=0; i<4; ++i){
            b[i] = s2.charAt(i);
            if(b[i]=='X'){
                index = i;
            }
        }
        if(index==1){
            b[1] = b[0];
            b[0] = 'X';
        }
        if(index==2){
            b[2] = b[0];
            b[0] = 'X';
        }
        if(index==3){
            b[3] = b[1];
            b[1] = b[0];
            b[0] = 'X';
        }
        temp = b[2];
        b[2] = b[3];
        b[3] = temp;
        char[] c = new char[6];
        for(int i=0; i<6; ++i){
            c[i] = a[i%2+1];
        }
        char[] d = new char[6];
        for(int i=0; i<6; ++i){
            d[i] = b[i%2+1];
        }
        int i;
        for(i=0; i<6; ++i){
            if(c[i]==d[0]){
                break;
            }
        }
        boolean flag = true;
        if(d[1] != c[index+1]){
            flag = false;
        }
        else{
            if(d[2] != c[index+2]){
                flag = false;
            }
        }
        if(flag){
            out.println("YES");
        }
        else{
            out.println("NO");
        }

    }

    public static void main(String[] args) throws Exception {
        solve();
        out.close();
    }

    private static class InputReader {
        private InputStream stream;
        private byte[] buffer;
        private int currentIndex;
        private int bytesRead;

        public InputReader(InputStream stream) {
            this.stream = stream;
            buffer = new byte[131072];
        }

        public InputReader(InputStream stream, int bufferSize) {
            this.stream = stream;
            buffer = new byte[bufferSize];
        }

        private int read() throws IOException {
            if (currentIndex >= bytesRead) {
                currentIndex = 0;
                bytesRead = stream.read(buffer);
                if (bytesRead <= 0) {
                    return -1;
                }
            }
            return buffer[currentIndex++];
        }

        public String readString() throws IOException {
            int c = read();
            while (!isPrintable(c)) {
                c = read();
            }
            StringBuilder result = new StringBuilder();
            do {
                result.appendCodePoint(c);
                c = read();
            } while (isPrintable(c));
            return result.toString();
        }

        public int readInt() throws Exception {
            int c = read();
            int sign = 1;
            while (!isPrintable(c)) {
                c = read();
            }
            if (c == '-') {
                sign = -1;
                c = read();
            }
            int result = 0;
            do {
                if ((c < '0') || (c > '9')) {
                    throw new InputMismatchException();
                }
                result *= 10;
                result += (c - '0');
                c = read();
            } while (isPrintable(c));
            return sign * result;
        }

        public long readLong() throws Exception {
            int c = read();
            int sign = 1;
            while (!isPrintable(c)) {
                c = read();
            }
            if (c == '-') {
                sign = -1;
                c = read();
            }
            long result = 0;
            do {
                if ((c < '0') || (c > '9')) {
                    throw new InputMismatchException();
                }
                result *= 10;
                result += (c - '0');
                c = read();
            } while (isPrintable(c));
            return sign * result;
        }

        public double readDouble() throws Exception {
            int c = read();
            int sign = 1;
            while (!isPrintable(c)) {
                c = read();
            }
            if (c == '-') {
                sign = -1;
                c = read();
            }
            boolean fraction = false;
            double multiplier = 1;
            double result = 0;
            do {
                if ((c == 'e') || (c == 'E')) {
                    return sign * result * Math.pow(10, readInt());
                }
                if ((c < '0') || (c > '9')) {
                    if ((c == '.') && (!fraction)) {
                        fraction = true;
                        c = read();
                        continue;
                    }
                    throw new InputMismatchException();
                }
                if (fraction) {
                    multiplier /= 10;
                    result += (c - '0') * multiplier;
                    c = read();
                } else {
                    result *= 10;
                    result += (c - '0');
                    c = read();
                }
            } while (isPrintable(c));
            return sign * result;
        }

        private boolean isPrintable(int c) {
            return ((c > 32) && (c < 127));
        }
    }

    private static class OutputWriter {
        private PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void print(Object... objects) {
            for (int i = 0; i < objects.length; i++) {
                if (i != 0) {
                    writer.print(' ');
                }
                writer.print(objects[i]);
            }
        }

        public void println(Object... objects) {
            print(objects);
            writer.println();
        }

        public void close() {
            writer.close();
        }

        public void flush() {
            writer.flush();
        }
    }
}

import java.io.*;
import java.math.*;
import java.util.*;

public class main {

    private static PrintWriter out;
    private static class FastScanner {
        BufferedReader br;
        StringTokenizer st;
        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

    }

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));
        String a = sc.nextLine() + sc.nextLine();
        String b = sc.nextLine() + sc.nextLine();

        String [] possibilities = {"XBAC", "BXAC", "BCAX", "BCXA",
        		"XCBA", "CXBA", "CABX", "CAXB",
        		"XACB", "AXCB", "ABCX", "ABXC"};
        boolean flag = false;
        for(int i = 0; i < 12; i ++)
        {
        	if(possibilities[i].replace('X', b.charAt(0)).replace('B', b.charAt(1)).replace('A', b.charAt(2)).replace('C', b.charAt(3)).equals(a))
        	{
        		flag = true;
        		out.println("YES");
        		break;
        	}
        }
        if(!flag) out.println("NO");

        out.close();
    }
}

import java.io.*;
import java.math.*;
import java.util.*;

public class main {

    private static PrintWriter out;
    private static class FastScanner {
        BufferedReader br;
        StringTokenizer st;
        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

    }

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));
        String a = sc.nextLine() + sc.nextLine();
        String b = sc.nextLine() + sc.nextLine();

        String [] possibilities = {"XBAC", "BXAC", "BCAX", "BCXA",
        		"XCBA", "CXBA", "CABX", "CAXB",
        		"XACB", "AXCB", "ABCX", "ABXC"};
        boolean flag = false;
        for(int i = 0; i < 12; i ++)
        {
        	if(possibilities[i].replace('X', b.charAt(0)).replace('B', b.charAt(1)).replace('A', b.charAt(2)).replace('C', b.charAt(3)).equals(a))
        	{
        		flag = true;
        		out.println("YES");
        		break;
        	}
        	if(possibilities[i].replace('X', a.charAt(0)).replace('B', a.charAt(1)).replace('A', a.charAt(2)).replace('C', a.charAt(3)).equals(b))
        	{
        		flag = true;
        		out.println("YES");
        		break;
        	}
        }
        if(!flag) out.println("NO");

        out.close();
    }
}

import java.util.*;
import java.io.*;

public class CF655A_2{
  public static int index;
  public static void main(String[] args)throws Exception {
    InputReader in = new InputReader(System.in);
    PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out));
  //  int n = in.nextInt();
    char[] a = in.next().toCharArray(), b = in.next().toCharArray();
    char[] c = in.next().toCharArray(), d = in.next().toCharArray();

    String up = ""+a[0]+b[0]+b[1]+a[1];
    String dn = ""+c[0]+d[0]+d[1]+c[1];

    for(int i = 0; i < 4; i++){
      int idx = dn.indexOf('X');
      dn = swap(dn, idx);
     // System.out.println(dn);
      if(up.equals(dn)){
        System.out.println("YES");
        return;
      }
    }

    System.err.println("NO");

    pw.close();
  }

  static String swap(String s, int i){
    char [] a = s.toCharArray();

    if(i == 3){
      char t = a[i];
      a[i] = a[0];
      a[0] = t;
    }
    else{
      char t = a[i];
      a[i] = a[i+1];
      a[i+1] = t;
    }
    return String.valueOf(a);
  }

  static class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
      reader = new BufferedReader(new InputStreamReader(stream));
      tokenizer = null;
    }

    public String next() {

      try {
        while (tokenizer == null || !tokenizer.hasMoreTokens())
          tokenizer = new StringTokenizer(reader.readLine());
      } catch (IOException e) {
        return null;
      }

      return tokenizer.nextToken();
    }

    public String nextLine() {
      String line = null;
      try {
        tokenizer = null;
        line =  reader.readLine();
      } catch (IOException e) {
        throw new RuntimeException(e);
      }
      return line;
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public long nextLong() {
      return Long.parseLong(next());
    }
    public boolean hasNext(){
      try {
        while (tokenizer == null || !tokenizer.hasMoreTokens())
          tokenizer = new StringTokenizer(reader.readLine());
      }
      catch (Exception e) {
        return false;
      }

    return true;

    }
  }
}

import java.util.*;
import java.io.*;

public class CF655A_2{
  public static int index;
  public static void main(String[] args)throws Exception {
    InputReader in = new InputReader(System.in);
    PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out));
  //  int n = in.nextInt();
    char[] a = in.next().toCharArray(), b = in.next().toCharArray();
    char[] c = in.next().toCharArray(), d = in.next().toCharArray();

    String up = ""+a[0]+b[0]+b[1]+a[1];
    String dn = ""+c[0]+d[0]+d[1]+c[1];

    for(int i = 0; i < 5; i++){
      int idx = dn.indexOf('X');
      dn = swap(dn, idx);
     // System.out.println(dn);
      if(up.equals(dn)){
        System.out.println("YES");
        return;
      }
    }

    System.out.println("NO");

    pw.close();
  }

  static String swap(String s, int i){
    char [] a = s.toCharArray();

    if(i == 3){
      char t = a[i];
      a[i] = a[0];
      a[0] = t;
    }
    else{
      char t = a[i];
      a[i] = a[i+1];
      a[i+1] = t;
    }
    return String.valueOf(a);
  }

  static class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
      reader = new BufferedReader(new InputStreamReader(stream));
      tokenizer = null;
    }

    public String next() {

      try {
        while (tokenizer == null || !tokenizer.hasMoreTokens())
          tokenizer = new StringTokenizer(reader.readLine());
      } catch (IOException e) {
        return null;
      }

      return tokenizer.nextToken();
    }

    public String nextLine() {
      String line = null;
      try {
        tokenizer = null;
        line =  reader.readLine();
      } catch (IOException e) {
        throw new RuntimeException(e);
      }
      return line;
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public long nextLong() {
      return Long.parseLong(next());
    }
    public boolean hasNext(){
      try {
        while (tokenizer == null || !tokenizer.hasMoreTokens())
          tokenizer = new StringTokenizer(reader.readLine());
      }
      catch (Exception e) {
        return false;
      }

    return true;

    }
  }
}

import java.util.*;
import java.io.*;

public class CF655A{
  public static int index;
  public static void main(String[] args)throws Exception {
    InputReader in = new InputReader(System.in);
    PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out));
  //  int n = in.nextInt();
    char[] a = in.next().toCharArray(), b = in.next().toCharArray();
    char[] c = in.next().toCharArray(), d = in.next().toCharArray();

    if(a[0] == c[0] && a[0]!= 'X' && a[1] == c[1]&& c[1]!= 'X') pw.println("YES");
    else if(a[0] == c[0] && a[0] != 'X' && b[0] == d[0]&& d[0]!= 'X') pw.println("YES");
    else if(b[0] == d[0] && b[0]!= 'X' && b[1] == d[1]&& d[1]!= 'X') pw.println("YES");
    else if(a[1] == c[1] && a[1]!= 'X' && b[1] == d[1]&& d[1]!= 'X') pw.println("YES");
    else pw.println("NO");

    pw.close();
  }

  static class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
      reader = new BufferedReader(new InputStreamReader(stream));
      tokenizer = null;
    }

    public String next() {

      try {
        while (tokenizer == null || !tokenizer.hasMoreTokens())
          tokenizer = new StringTokenizer(reader.readLine());
      } catch (IOException e) {
        return null;
      }

      return tokenizer.nextToken();
    }

    public String nextLine() {
      String line = null;
      try {
        tokenizer = null;
        line =  reader.readLine();
      } catch (IOException e) {
        throw new RuntimeException(e);
      }
      return line;
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public long nextLong() {
      return Long.parseLong(next());
    }
    public boolean hasNext(){
      try {
        while (tokenizer == null || !tokenizer.hasMoreTokens())
          tokenizer = new StringTokenizer(reader.readLine());
      }
      catch (Exception e) {
        return false;
      }

    return true;

    }
  }
}

import java.util.*;
import java.io.*;

public class CF655A{
  public static int index;
  public static void main(String[] args)throws Exception {
    InputReader in = new InputReader(System.in);
    PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out));
  //  int n = in.nextInt();
    char[] a = in.next().toCharArray(), b = in.next().toCharArray();
    char[] c = in.next().toCharArray(), d = in.next().toCharArray();

    if(a[0] == c[0] && a[1] == c[1]) pw.println("YES");
    else if(a[0] == c[0] && b[0] == d[0]) pw.println("YES");
    else if(b[0] == d[0] && b[1] == d[1]) pw.println("YES");
    else if(a[1] == c[1] && b[1] == d[1]) pw.println("YES");
    else pw.println("NO");

    pw.close();
  }

  static class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
      reader = new BufferedReader(new InputStreamReader(stream));
      tokenizer = null;
    }

    public String next() {

      try {
        while (tokenizer == null || !tokenizer.hasMoreTokens())
          tokenizer = new StringTokenizer(reader.readLine());
      } catch (IOException e) {
        return null;
      }

      return tokenizer.nextToken();
    }

    public String nextLine() {
      String line = null;
      try {
        tokenizer = null;
        line =  reader.readLine();
      } catch (IOException e) {
        throw new RuntimeException(e);
      }
      return line;
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public long nextLong() {
      return Long.parseLong(next());
    }
    public boolean hasNext(){
      try {
        while (tokenizer == null || !tokenizer.hasMoreTokens())
          tokenizer = new StringTokenizer(reader.readLine());
      }
      catch (Exception e) {
        return false;
      }

    return true;

    }
  }
}

import java.util.*;
import java.io.*;

public class CF655A_2{
  public static int index;
  public static void main(String[] args)throws Exception {
    InputReader in = new InputReader(System.in);
    PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out));
  //  int n = in.nextInt();
    char[] a = in.next().toCharArray(), b = in.next().toCharArray();
    char[] c = in.next().toCharArray(), d = in.next().toCharArray();

    String up = ""+a[0]+b[0]+b[1]+a[1];
    String dn = ""+c[0]+d[0]+d[1]+c[1];

    for(int i = 0; i < 4; i++){
      int idx = dn.indexOf('X');
      dn = swap(dn, idx);
     // System.out.println(dn);
      if(up.equals(dn)){
        System.out.println("YES");
        return;
      }
    }

    System.out.println("NO");

    pw.close();
  }

  static String swap(String s, int i){
    char [] a = s.toCharArray();

    if(i == 3){
      char t = a[i];
      a[i] = a[0];
      a[0] = t;
    }
    else{
      char t = a[i];
      a[i] = a[i+1];
      a[i+1] = t;
    }
    return String.valueOf(a);
  }

  static class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
      reader = new BufferedReader(new InputStreamReader(stream));
      tokenizer = null;
    }

    public String next() {

      try {
        while (tokenizer == null || !tokenizer.hasMoreTokens())
          tokenizer = new StringTokenizer(reader.readLine());
      } catch (IOException e) {
        return null;
      }

      return tokenizer.nextToken();
    }

    public String nextLine() {
      String line = null;
      try {
        tokenizer = null;
        line =  reader.readLine();
      } catch (IOException e) {
        throw new RuntimeException(e);
      }
      return line;
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public long nextLong() {
      return Long.parseLong(next());
    }
    public boolean hasNext(){
      try {
        while (tokenizer == null || !tokenizer.hasMoreTokens())
          tokenizer = new StringTokenizer(reader.readLine());
      }
      catch (Exception e) {
        return false;
      }

    return true;

    }
  }
}

import java.util.Arrays;
import java.util.Scanner;

public class P655A
{
	public static void main(String[] args)
	{
		Scanner scan = new Scanner(System.in);
		char[][] bessie = new char[2][2];
		for (int i = 0; i < 2; i++)
			bessie[i] = scan.nextLine().toCharArray();
		char[][] elsie = new char[2][2];
		for (int i = 0; i < 2; i++)
			elsie[i] = scan.nextLine().toCharArray();
		for (int i = 0; i < 4; i++)
		{
			if (Arrays.deepEquals(bessie, elsie))
			{
				System.out.println("YES");
				return;
			}
			bessie = rotateClockwise(bessie);
		}
		System.out.println("NO");
		scan.close();
	}
	//moves the X clockwise
	private static char[][] rotateClockwise(char[][] arr)
	{
		if (arr[0][0] == 'X')
			return new char[][] { { arr[0][1], arr[0][0] },{ arr[1][0], arr[1][1] } };
		if (arr[0][1] == 'X')
			return new char[][] { { arr[0][0], arr[1][1] },{ arr[1][0], arr[0][1] } };
		if (arr[1][1] == 'X')
			return new char[][] { { arr[0][0], arr[0][1] },{ arr[1][1], arr[1][0] } };
		return new char[][] { { arr[1][0], arr[0][1] },{ arr[0][0], arr[1][1] } };
	}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Bessie {

	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		char bessie[][] = new char[2][2];
		String s1 = br.readLine();
		String s2 = br.readLine();

		bessie[0][0] = s1.charAt(0);
		bessie[0][1] = s1.charAt(1);
		bessie[1][0] = s2.charAt(0);
		bessie[1][1] = s2.charAt(1);

		String order = "";

		order = s1 + s2.charAt(1) + s2.charAt(0);

		s1 = br.readLine();
		s2 = br.readLine();

		String order2 = "";

		order2 = s1 + s2.charAt(1) + s2.charAt(0);

		char first = order.charAt(0);

		int i = 0;
		while (order2.charAt(i) != first) {
			i++;
		}

		String ox = "" + order2.charAt(i);
		for (int tt = i + 1, count = 0; count < 4; ++tt, count++) {
			tt %= 4;
			ox += order2.charAt(tt);
		}

		order2 = ox;

		int j = 0;
		for (i = 0, j = 0; i < 4 && j < 4; j++, i++)
			if (order.charAt(i) != order2.charAt(j)) {
				if (order.charAt(i) == 'X') {
					j--;
				} else if (order2.charAt(j) == 'X') {
					i--;
				} else {
					System.out.println("NO");
					return;
				}
			}

		System.out.println("YES");
	}
}

//package CodeForces.KrokChamp2016o;

import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * Created by ilya on 18.03.16.
 */

public class A655 {
    public static void main(String[] args) {
        sc sc = new sc();
        PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
        char[][] a = new char[2][2];
        char[][] b = new char[2][2];
        String str = sc.next();
        a[0][0] = str.charAt(0);
        a[0][1] = str.charAt(1);
        str = sc.next();
        a[1][0] = str.charAt(0);
        a[1][1] = str.charAt(1);
        str = sc.next();
        b[0][0] = str.charAt(0);
        b[0][1] = str.charAt(1);
        str = sc.next();
        b[1][0] = str.charAt(0);
        b[1][1] = str.charAt(1);
        for (int i = 0; i < 2; i++) {
            for (int j = 0; j < 2; j++) {
                if (a[i][j] == 'X') {
                    for (int k = 0; k < 2; k++) {
                        for (int l = 0; l < 2; l++) {
                            if (b[k][l] == 'X') {
                                if (k != i) {
                                    char tmp = b[(k+1)%2][l];
                                    b[(k+1)%2][l] = b[k][l];
                                    b[k][l] = tmp;
                                }
                                if (l != j){
                                    char tmp = b[k][(l+1)%2];
                                    b[k][(l+1)%2] = b[k][l];
                                    b[k][l] = tmp;
                                }
                                if (b[(k+1)%2][l]!=a[(k+1)%2][l] || b[k][(l+1)%2]!=a[k][(l+1)%2]) {
                                    out.println("NO");
                                    out.close();
                                    return;
                                } else {
                                    out.println("YES");
                                    out.close();
                                    return;
                                }

                            }
                        }
                    }
                }
            }
        }
        out.close();
    }

    public static class sc {
        BufferedReader br;
        StringTokenizer st;

        public sc() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        Integer nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

}

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.SortedSet;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

/**
 * #
 * @author pttrung
 */
public class A_CROC2016_Eli {

    public static long MOD = 1000000007;

    public static void main(String[] args) throws FileNotFoundException {
        // PrintWriter out = new PrintWriter(new FileOutputStream(new File(
        // "output.txt")));
        PrintWriter out = new PrintWriter(System.out);
        Scanner in = new Scanner();
        char[][][] data = new char[2][2][2];
        for (int i = 0; i < 2; i++) {
            for (int j = 0; j < 2; j++) {
                data[i][j] = in.next().toCharArray();
            }
        }
        int x = -1, y = -1;
        for (int i = 0; i < 2; i++) {
            for (int j = 0; j < 2; j++) {
                if (data[1][i][j] == 'X') {
                    x = i;
                    y = j;
                }
            }
        }
        boolean found = false;
        boolean ok = true;

        for (int i = 0; i < 2 && !found; i++) {
            for (int j = 0; j < 2; j++) {
                if (data[0][i][j] == 'X') {
                    if (x != i) {
                        data[0][i][j] = data[0][x][j];
                        data[0][x][j] = 'X';
                    }

                    for (int k = 0; k < 2; k++) {

                        ok &= Arrays.equals(data[0][k], data[1][k]);
                    }
                    if (!ok) {
                        ok = true;
                        if (y != j) {
                            data[0][x][y] = data[0][x][j];
                            data[0][x][j] = 'X';
                        }
                        if (x != i) {
                            data[0][x][j] = data[0][i][j];
                            data[0][i][j] = 'X';
                        }
                        if (y != j) {
                            data[0][i][j] = data[0][i][y];
                            data[0][i][y] = 'X';
                        }
                        if (x != i) {
                            data[0][x][j] = data[0][x][y];
                            data[0][x][y] = 'X';
                        }
                    }
                    found = true;
                    break;
                }
            }
        }

        if (ok) {
            out.println("YES");
        } else {
            out.println("NO");
        }
        out.close();
    }

    public static int[] KMP(String val) {
        int i = 0;
        int j = -1;
        int[] result = new int[val.length() + 1];
        result[0] = -1;
        while (i < val.length()) {
            while (j >= 0 && val.charAt(j) != val.charAt(i)) {
                j = result[j];
            }
            j++;
            i++;
            result[i] = j;
        }
        return result;

    }

    public static boolean nextPer(int[] data) {
        int i = data.length - 1;
        while (i > 0 && data[i] < data[i - 1]) {
            i--;
        }
        if (i == 0) {
            return false;
        }
        int j = data.length - 1;
        while (data[j] < data[i - 1]) {
            j--;
        }
        int temp = data[i - 1];
        data[i - 1] = data[j];
        data[j] = temp;
        Arrays.sort(data, i, data.length);
        return true;
    }

    public static int digit(long n) {
        int result = 0;
        while (n > 0) {
            n /= 10;
            result++;
        }
        return result;
    }

    public static double dist(long a, long b, long x, long y) {
        double val = (b - a) * (b - a) + (x - y) * (x - y);
        val = Math.sqrt(val);
        double other = x * x + a * a;
        other = Math.sqrt(other);
        return val + other;

    }

    public static class Point implements Comparable<Point> {

        int x, y;

        public Point(int start, int end) {
            this.x = start;
            this.y = end;
        }

        @Override
        public int hashCode() {
            int hash = 5;
            hash = 47 * hash + this.x;
            hash = 47 * hash + this.y;
            return hash;
        }

        @Override
        public boolean equals(Object obj) {
            if (obj == null) {
                return false;
            }
            if (getClass() != obj.getClass()) {
                return false;
            }
            final Point other = (Point) obj;
            if (this.x != other.x) {
                return false;
            }
            if (this.y != other.y) {
                return false;
            }
            return true;
        }

        @Override
        public int compareTo(Point o) {
            return x - o.x;
        }
    }

    public static class FT {

        long[] data;

        FT(int n) {
            data = new long[n];
        }

        public void update(int index, long value) {
            while (index < data.length) {
                data[index] += value;
                index += (index & (-index));
            }
        }

        public long get(int index) {
            long result = 0;
            while (index > 0) {
                result += data[index];
                index -= (index & (-index));
            }
            return result;

        }
    }

    public static long gcd(long a, long b) {
        if (b == 0) {
            return a;
        }
        return gcd(b, a % b);
    }

    public static long pow(long a, long b, long MOD) {
        if (b == 0) {
            return 1;
        }
        if (b == 1) {
            return a;
        }
        long val = pow(a, b / 2, MOD);
        if (b % 2 == 0) {
            return val * val % MOD;
        } else {
            return val * (val * a % MOD) % MOD;

        }
    }

    static class Scanner {

        BufferedReader br;
        StringTokenizer st;

        public Scanner() throws FileNotFoundException {
            // System.setOut(new PrintStream(new BufferedOutputStream(System.out), true));
            br = new BufferedReader(new InputStreamReader(System.in));
            //  br = new BufferedReader(new InputStreamReader(new FileInputStream(new File("input.txt"))));
        }

        public String next() {

            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception e) {
                    throw new RuntimeException();
                }
            }
            return st.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public String nextLine() {
            st = null;
            try {
                return br.readLine();
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }

        public boolean endLine() {
            try {
                String next = br.readLine();
                while (next != null && next.trim().isEmpty()) {
                    next = br.readLine();
                }
                if (next == null) {
                    return true;
                }
                st = new StringTokenizer(next);
                return st.hasMoreTokens();
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }
    }
}

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.SortedSet;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

/**
 * #
 * @author pttrung
 */
public class A_CROC2016_Eli {

    public static long MOD = 1000000007;

    public static void main(String[] args) throws FileNotFoundException {
        // PrintWriter out = new PrintWriter(new FileOutputStream(new File(
        // "output.txt")));
        PrintWriter out = new PrintWriter(System.out);
        Scanner in = new Scanner();
        char[][][] data = new char[2][2][2];
        for (int i = 0; i < 2; i++) {
            for (int j = 0; j < 2; j++) {
                data[i][j] = in.next().toCharArray();
            }
        }

        boolean found = false;
        boolean ok = false;
        int[][] pos = {{0, 1}, {3, 2}};
        int[] X = {0, 0, 1, 1};
        int[] Y = {0, 1, 1, 0};
        for (int i = 0; i < 2 && !found; i++) {
            for (int j = 0; j < 2; j++) {
                if (data[0][i][j] == 'X') {
                    int cur = pos[i][j];
                    for (int k = 0; k < 4; k++) {
                        int nxt = (cur + 1) % 4;
                        int x = X[nxt];
                        int y = Y[nxt];
                        if (x != X[cur]) {
                            data[0][X[cur]][y] = data[0][x][y];
                            data[0][x][y] = 'X';
                        } else {
                            data[0][x][Y[cur]] = data[0][x][y];
                            data[0][x][y] = 'X';
                        }
                        ok |= (Arrays.equals(data[0][0], data[1][0]) && Arrays.equals(data[0][1], data[1][1]));
                        cur = nxt;
                    }
                    for (int k = 0; k < 4; k++) {
                        int nxt = (cur + 3) % 4;
                        int x = X[nxt];
                        int y = Y[nxt];
                        if (x != X[cur]) {
                            data[0][X[cur]][y] = data[0][x][y];
                            data[0][x][y] = 'X';
                        } else {
                            data[0][x][Y[cur]] = data[0][x][y];
                            data[0][x][y] = 'X';
                        }
                        ok |= (Arrays.equals(data[0][0], data[1][0]) && Arrays.equals(data[0][1], data[1][1]));
                        cur = nxt;
                    }
                    found = true;
                    break;
                }
            }
        }

        if (ok) {
            out.println("YES");
        } else {
            out.println("NO");
        }
        out.close();
    }

    public static int[] KMP(String val) {
        int i = 0;
        int j = -1;
        int[] result = new int[val.length() + 1];
        result[0] = -1;
        while (i < val.length()) {
            while (j >= 0 && val.charAt(j) != val.charAt(i)) {
                j = result[j];
            }
            j++;
            i++;
            result[i] = j;
        }
        return result;

    }

    public static boolean nextPer(int[] data) {
        int i = data.length - 1;
        while (i > 0 && data[i] < data[i - 1]) {
            i--;
        }
        if (i == 0) {
            return false;
        }
        int j = data.length - 1;
        while (data[j] < data[i - 1]) {
            j--;
        }
        int temp = data[i - 1];
        data[i - 1] = data[j];
        data[j] = temp;
        Arrays.sort(data, i, data.length);
        return true;
    }

    public static int digit(long n) {
        int result = 0;
        while (n > 0) {
            n /= 10;
            result++;
        }
        return result;
    }

    public static double dist(long a, long b, long x, long y) {
        double val = (b - a) * (b - a) + (x - y) * (x - y);
        val = Math.sqrt(val);
        double other = x * x + a * a;
        other = Math.sqrt(other);
        return val + other;

    }

    public static class Point implements Comparable<Point> {

        int x, y;

        public Point(int start, int end) {
            this.x = start;
            this.y = end;
        }

        @Override
        public int hashCode() {
            int hash = 5;
            hash = 47 * hash + this.x;
            hash = 47 * hash + this.y;
            return hash;
        }

        @Override
        public boolean equals(Object obj) {
            if (obj == null) {
                return false;
            }
            if (getClass() != obj.getClass()) {
                return false;
            }
            final Point other = (Point) obj;
            if (this.x != other.x) {
                return false;
            }
            if (this.y != other.y) {
                return false;
            }
            return true;
        }

        @Override
        public int compareTo(Point o) {
            return x - o.x;
        }
    }

    public static class FT {

        long[] data;

        FT(int n) {
            data = new long[n];
        }

        public void update(int index, long value) {
            while (index < data.length) {
                data[index] += value;
                index += (index & (-index));
            }
        }

        public long get(int index) {
            long result = 0;
            while (index > 0) {
                result += data[index];
                index -= (index & (-index));
            }
            return result;

        }
    }

    public static long gcd(long a, long b) {
        if (b == 0) {
            return a;
        }
        return gcd(b, a % b);
    }

    public static long pow(long a, long b, long MOD) {
        if (b == 0) {
            return 1;
        }
        if (b == 1) {
            return a;
        }
        long val = pow(a, b / 2, MOD);
        if (b % 2 == 0) {
            return val * val % MOD;
        } else {
            return val * (val * a % MOD) % MOD;

        }
    }

    static class Scanner {

        BufferedReader br;
        StringTokenizer st;

        public Scanner() throws FileNotFoundException {
            // System.setOut(new PrintStream(new BufferedOutputStream(System.out), true));
            br = new BufferedReader(new InputStreamReader(System.in));
            //  br = new BufferedReader(new InputStreamReader(new FileInputStream(new File("input.txt"))));
        }

        public String next() {

            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception e) {
                    throw new RuntimeException();
                }
            }
            return st.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public String nextLine() {
            st = null;
            try {
                return br.readLine();
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }

        public boolean endLine() {
            try {
                String next = br.readLine();
                while (next != null && next.trim().isEmpty()) {
                    next = br.readLine();
                }
                if (next == null) {
                    return true;
                }
                st = new StringTokenizer(next);
                return st.hasMoreTokens();
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }
    }
}

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.SortedSet;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

/**
 * #
 * @author pttrung
 */
public class A_CROC2016_Eli {

    public static long MOD = 1000000007;

    public static void main(String[] args) throws FileNotFoundException {
        // PrintWriter out = new PrintWriter(new FileOutputStream(new File(
        // "output.txt")));
        PrintWriter out = new PrintWriter(System.out);
        Scanner in = new Scanner();
        char[][][] data = new char[2][2][2];
        for (int i = 0; i < 2; i++) {
            for (int j = 0; j < 2; j++) {
                data[i][j] = in.next().toCharArray();
            }
        }
        int x = -1, y = -1;
        for (int i = 0; i < 2; i++) {
            for (int j = 0; j < 2; j++) {
                if (data[1][i][j] == 'X') {
                    x = i;
                    y = j;
                }
            }
        }
        boolean found = false;
        boolean ok = true;

        for (int i = 0; i < 2 && !found; i++) {
            for (int j = 0; j < 2; j++) {
                if (data[0][i][j] == 'X') {
                    if (x != i) {
                        data[0][i][j] = data[0][x][j];
                        data[0][x][j] = 'X';
                    }
                    if (y != j) {
                        data[0][x][j] = data[0][x][y];
                        data[0][x][y] = 'X';
                    }

                    for (int k = 0; k < 2; k++) {

                        ok &= Arrays.equals(data[0][k], data[1][k]);
                    }
                    if (!ok) {
                        ok = true;
                        if (y != j) {
                            data[0][x][y] = data[0][x][j];
                            data[0][x][j] = 'X';
                        }
                        if (x != i) {
                            data[0][x][j] = data[0][i][j];
                            data[0][i][j] = 'X';
                        }
                      //  System.out.println(Arrays.toString(data[0][0]));
                      //  System.out.println(Arrays.toString(data[0][1]));
                        if (y != j) {
                            data[0][i][j] = data[0][i][y];
                            data[0][i][y] = 'X';
                        }
                        if (x != i) {
                            data[0][i][y] = data[0][x][y];
                            data[0][x][y] = 'X';
                        }
                      //  System.out.println(Arrays.toString(data[0][0]));
                      //  System.out.println(Arrays.toString(data[0][1]));
                        for (int k = 0; k < 2; k++) {

                            ok &= Arrays.equals(data[0][k], data[1][k]);
                        }
                    }
                    found = true;
                    break;
                }
            }
        }

        if (ok) {
            out.println("YES");
        } else {
            out.println("NO");
        }
        out.close();
    }

    public static int[] KMP(String val) {
        int i = 0;
        int j = -1;
        int[] result = new int[val.length() + 1];
        result[0] = -1;
        while (i < val.length()) {
            while (j >= 0 && val.charAt(j) != val.charAt(i)) {
                j = result[j];
            }
            j++;
            i++;
            result[i] = j;
        }
        return result;

    }

    public static boolean nextPer(int[] data) {
        int i = data.length - 1;
        while (i > 0 && data[i] < data[i - 1]) {
            i--;
        }
        if (i == 0) {
            return false;
        }
        int j = data.length - 1;
        while (data[j] < data[i - 1]) {
            j--;
        }
        int temp = data[i - 1];
        data[i - 1] = data[j];
        data[j] = temp;
        Arrays.sort(data, i, data.length);
        return true;
    }

    public static int digit(long n) {
        int result = 0;
        while (n > 0) {
            n /= 10;
            result++;
        }
        return result;
    }

    public static double dist(long a, long b, long x, long y) {
        double val = (b - a) * (b - a) + (x - y) * (x - y);
        val = Math.sqrt(val);
        double other = x * x + a * a;
        other = Math.sqrt(other);
        return val + other;

    }

    public static class Point implements Comparable<Point> {

        int x, y;

        public Point(int start, int end) {
            this.x = start;
            this.y = end;
        }

        @Override
        public int hashCode() {
            int hash = 5;
            hash = 47 * hash + this.x;
            hash = 47 * hash + this.y;
            return hash;
        }

        @Override
        public boolean equals(Object obj) {
            if (obj == null) {
                return false;
            }
            if (getClass() != obj.getClass()) {
                return false;
            }
            final Point other = (Point) obj;
            if (this.x != other.x) {
                return false;
            }
            if (this.y != other.y) {
                return false;
            }
            return true;
        }

        @Override
        public int compareTo(Point o) {
            return x - o.x;
        }
    }

    public static class FT {

        long[] data;

        FT(int n) {
            data = new long[n];
        }

        public void update(int index, long value) {
            while (index < data.length) {
                data[index] += value;
                index += (index & (-index));
            }
        }

        public long get(int index) {
            long result = 0;
            while (index > 0) {
                result += data[index];
                index -= (index & (-index));
            }
            return result;

        }
    }

    public static long gcd(long a, long b) {
        if (b == 0) {
            return a;
        }
        return gcd(b, a % b);
    }

    public static long pow(long a, long b, long MOD) {
        if (b == 0) {
            return 1;
        }
        if (b == 1) {
            return a;
        }
        long val = pow(a, b / 2, MOD);
        if (b % 2 == 0) {
            return val * val % MOD;
        } else {
            return val * (val * a % MOD) % MOD;

        }
    }

    static class Scanner {

        BufferedReader br;
        StringTokenizer st;

        public Scanner() throws FileNotFoundException {
            // System.setOut(new PrintStream(new BufferedOutputStream(System.out), true));
            br = new BufferedReader(new InputStreamReader(System.in));
            //  br = new BufferedReader(new InputStreamReader(new FileInputStream(new File("input.txt"))));
        }

        public String next() {

            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception e) {
                    throw new RuntimeException();
                }
            }
            return st.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public String nextLine() {
            st = null;
            try {
                return br.readLine();
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }

        public boolean endLine() {
            try {
                String next = br.readLine();
                while (next != null && next.trim().isEmpty()) {
                    next = br.readLine();
                }
                if (next == null) {
                    return true;
                }
                st = new StringTokenizer(next);
                return st.hasMoreTokens();
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }
    }
}

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.SortedSet;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

/**
 * #
 * @author pttrung
 */
public class A_CROC2016_Eli {

    public static long MOD = 1000000007;

    public static void main(String[] args) throws FileNotFoundException {
        // PrintWriter out = new PrintWriter(new FileOutputStream(new File(
        // "output.txt")));
        PrintWriter out = new PrintWriter(System.out);
        Scanner in = new Scanner();
        char[][][]data = new char[2][2][2];
        for(int i = 0; i < 2; i++){
            for(int j = 0; j < 2; j++){
                data[i][j] = in.next().toCharArray();
            }
        }
        int x = -1, y = -1;
        for(int i = 0; i < 2; i++){
            for(int j = 0; j < 2; j++){
                if(data[1][i][j] == 'X'){
                    x = i;
                    y = j;
                }
            }
        }
        for(int i = 0; i < 2; i++){
            for(int j = 0; j < 2; j++){
                if(data[0][i][j] == 'X'){
                    if(x != i){
                        data[0][i][j] = data[0][x][j];
                        data[0][x][j] = 'X';
                    }
                    if(y != j){
                        data[0][x][j] = data[0][x][y];
                        data[0][x][y] = 'X';
                    }
                }
            }
        }
        boolean ok = true;
        for(int i = 0; i < 2; i++){

            ok &= Arrays.equals(data[0][i], data[1][i]);
        }
        if(ok){
            out.println("YES");
        }else{
            out.println("NO");
        }
        out.close();
    }

    public static int[] KMP(String val) {
        int i = 0;
        int j = -1;
        int[] result = new int[val.length() + 1];
        result[0] = -1;
        while (i < val.length()) {
            while (j >= 0 && val.charAt(j) != val.charAt(i)) {
                j = result[j];
            }
            j++;
            i++;
            result[i] = j;
        }
        return result;

    }

    public static boolean nextPer(int[] data) {
        int i = data.length - 1;
        while (i > 0 && data[i] < data[i - 1]) {
            i--;
        }
        if (i == 0) {
            return false;
        }
        int j = data.length - 1;
        while (data[j] < data[i - 1]) {
            j--;
        }
        int temp = data[i - 1];
        data[i - 1] = data[j];
        data[j] = temp;
        Arrays.sort(data, i, data.length);
        return true;
    }

    public static int digit(long n) {
        int result = 0;
        while (n > 0) {
            n /= 10;
            result++;
        }
        return result;
    }

    public static double dist(long a, long b, long x, long y) {
        double val = (b - a) * (b - a) + (x - y) * (x - y);
        val = Math.sqrt(val);
        double other = x * x + a * a;
        other = Math.sqrt(other);
        return val + other;

    }

    public static class Point implements Comparable<Point> {

        int x, y;

        public Point(int start, int end) {
            this.x = start;
            this.y = end;
        }

        @Override
        public int hashCode() {
            int hash = 5;
            hash = 47 * hash + this.x;
            hash = 47 * hash + this.y;
            return hash;
        }

        @Override
        public boolean equals(Object obj) {
            if (obj == null) {
                return false;
            }
            if (getClass() != obj.getClass()) {
                return false;
            }
            final Point other = (Point) obj;
            if (this.x != other.x) {
                return false;
            }
            if (this.y != other.y) {
                return false;
            }
            return true;
        }

        @Override
        public int compareTo(Point o) {
            return x - o.x;
        }
    }

    public static class FT {

        long[] data;

        FT(int n) {
            data = new long[n];
        }

        public void update(int index, long value) {
            while (index < data.length) {
                data[index] += value;
                index += (index & (-index));
            }
        }

        public long get(int index) {
            long result = 0;
            while (index > 0) {
                result += data[index];
                index -= (index & (-index));
            }
            return result;

        }
    }

    public static long gcd(long a, long b) {
        if (b == 0) {
            return a;
        }
        return gcd(b, a % b);
    }

    public static long pow(long a, long b, long MOD) {
        if (b == 0) {
            return 1;
        }
        if (b == 1) {
            return a;
        }
        long val = pow(a, b / 2, MOD);
        if (b % 2 == 0) {
            return val * val % MOD;
        } else {
            return val * (val * a % MOD) % MOD;

        }
    }

    static class Scanner {

        BufferedReader br;
        StringTokenizer st;

        public Scanner() throws FileNotFoundException {
            // System.setOut(new PrintStream(new BufferedOutputStream(System.out), true));
            br = new BufferedReader(new InputStreamReader(System.in));
            //  br = new BufferedReader(new InputStreamReader(new FileInputStream(new File("input.txt"))));
        }

        public String next() {

            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception e) {
                    throw new RuntimeException();
                }
            }
            return st.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public String nextLine() {
            st = null;
            try {
                return br.readLine();
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }

        public boolean endLine() {
            try {
                String next = br.readLine();
                while (next != null && next.trim().isEmpty()) {
                    next = br.readLine();
                }
                if (next == null) {
                    return true;
                }
                st = new StringTokenizer(next);
                return st.hasMoreTokens();
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }
    }
}

import java.io.*;
import java.util.*;

public class A {

	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;
	boolean eof;

	void solve() throws IOException {
		char[][] a = new char[2][2];
		char[][] b = new char[2][2];
		for (int i = 0; i < 2; i++) {
			a[i] = nextToken().toCharArray();
		}

		for (int i = 0; i < 2; i++) {
			b[i] = nextToken().toCharArray();
		}

		String s = "" + a[0][0] + a[0][1] + a[1][1] + a[1][0];
		String t = "" + b[0][0] + b[0][1] + b[1][1] + b[1][0];

		int x = t.indexOf(s.charAt(0));

		String ss = t.substring(x) + t.substring(0, x);

		x = s.indexOf('X');
		s = s.substring(0, x) + s.substring(x + 1);

		x = ss.indexOf('X');
		ss = ss.substring(0, x) + ss.substring(x + 1);

		out.println(s.equals(ss) ? "YES" : "NO");
	}

	A() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		solve();
		out.close();
	}

	public static void main(String[] args) throws IOException {
		new A();
	}

	String nextToken() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				eof = true;
				return null;
			}
		}
		return st.nextToken();
	}

	String nextString() {
		try {
			return br.readLine();
		} catch (IOException e) {
			eof = true;
			return null;
		}
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}
}

import java.util.*;

import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

import static java.lang.Integer.*;

public class Main {
	public static void main(String[] args) throws Exception{
		InputReader in = new InputReader(System.in);
		PrintWriter out = new PrintWriter(System.out);
		TaskA solver = new TaskA();
		solver.solve(1, in, out);
		out.close();
	}

static class TaskA {
  // GCD && LCM
	 long gcd(long a ,long b){return b == 0 ? a : gcd(b , a % b);}
	 long lcm(long a , long b){return a*(b/gcd(a, b));}

	 // REverse a String
	String rev(String s){
		return new StringBuilder(s).reverse().toString();
	}
	/*          SOLUTION  IS RIGHT HERE     */
	public void solve(int testNumber, InputReader in, PrintWriter out) throws IOException{
		 //BufferedReader  br = new BufferedReader(new InputStreamReader(System.in));
		//  Scanner sc = new Scanner(System.in);
      String s = in.next()+in.next();
	  char[] one = (s+s).toCharArray();
	  s = in.next()+in.next();
	  char[] two = (s+s).toCharArray();
	  String a ="" , b = "";
	  int i = 0;
	  while(one[i] != 'X')i++;
	  i++;
	  for(; i < one.length ; i++){
		  if(one[i] == 'X')break;
		  a += one[i];
	  }

	  i = 0;
	  while(two[i] != 'X')i++;
	  i++;
	  for(; i < two.length ; i++){
		  if(two[i] == 'X')break;
		  b += two[i];
	  }

	  int c = b.indexOf(a.charAt(0));
	  String cs = b.substring(c) + rev(b.substring(0 , c));
	 // out.println(a+" "+ b + " "+cs);
	  if(a.equals(cs))
		  out.println("YES");
	  else
		  out.println("NO");
  }
}

 // ||||||| INPUT READER ||||||||
 static class InputReader {
	private byte[] buf = new byte[8000];
	private int index;
	private int total;
	private InputStream in;
	BufferedReader br = new  BufferedReader(new InputStreamReader(System.in));
	public InputReader(InputStream stream){
		in = stream;
	}

	public int scan(){
		if(total == -1)
			throw new InputMismatchException();
		if(index >= total){
			index = 0;
			try{
			total = in.read(buf);
			}catch(IOException e){
			   throw new InputMismatchException();
			}
			if(total <= 0)
				return -1;
		}
		return buf[index++];
	}
	public long scanlong(){
		long integer = 0;
		int n = scan();
		while(isWhiteSpace(n))
			n = scan();
		int neg = 1;
		if(n == '-'){
			neg = -1;
			n = scan();
		}
		while(!isWhiteSpace(n)){
			if(n >= '0' && n <= '9'){
				integer *= 10;
				integer += n - '0';
				n = scan();
			}
			else throw new InputMismatchException();
		}
		return neg*integer;
	}

	private int scanInt() {
		int integer = 0;
		int n = scan();
		while(isWhiteSpace(n))
			n = scan();
		int neg = 1;
		if(n == '-'){
			neg = -1;
			n = scan();
		}
		while(!isWhiteSpace(n)){
			if(n >= '0' && n <= '9'){
				integer *= 10;
				integer += n - '0';
				n = scan();
			}
			else throw new InputMismatchException();
		}
		return neg*integer;
	}

	public double scandouble(){
		double doubll = 0;
		int n = scan();
		int neg = 1;
		while(isWhiteSpace(n))
			n = scan();
		if(n == '-'){
			neg = -1;
			n = scan();
		}
		while(!isWhiteSpace(n) && n != '.'){
			if(n >= '0' && n <= '9'){
				doubll *= 10;
				doubll += n - '0';
				n = scan();
			}
		}
		if(n == '.'){
			n = scan();
			double temp = 1;
			while(!isWhiteSpace(n)){
				if(n >= '0' && n <= '9'){
					temp /= 10;
					doubll += (n - '0')*temp;
					n = scan();
				}
			}
		}
		return neg*doubll;
	}

	private float scanfloat() {
		float doubll = 0;
		int n = scan();
		int neg = 1;
		while(isWhiteSpace(n))
			n = scan();
		if(n == '-'){
			neg = -1;
			n = scan();
		}
		while(!isWhiteSpace(n) && n != '.'){
			if(n >= '0' && n <= '9'){
				doubll *= 10;
				doubll += n - '0';
				n = scan();
			}
		}
		if(n == '.'){
			n = scan();
			double temp = 1;
			while(!isWhiteSpace(n)){
				if(n >= '0' && n <= '9'){
					temp /= 10;
					doubll += (n - '0')*temp;
					n = scan();
				}
			}
		}
		return neg*doubll;
	}
	public String scanstring(){
		StringBuilder sb = new StringBuilder();
		int n = scan();
		while(isWhiteSpace(n))
			n = scan();
		while(!isWhiteSpace(n)){
			sb.append((char)n);
			n = scan();
		}
		return sb.toString();
	}

	public String scan_nextLine() {
        int n = scan();
        while (isWhiteSpace(n))
            n = scan();
        StringBuilder res = new StringBuilder();
        do {
            res.appendCodePoint(n);
            n = scan();
        } while (!isEndOfLine(n));
        return res.toString();
    }
	public boolean isWhiteSpace(int n){
		if(n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1)
			return true;
		return false;
	}

	private boolean isEndOfLine(int c) {
        return c == '\n' || c == '\r' || c == -1;
    }
/// Input module

	public int nextInt(){
	  return scanInt();
	}

	public long nextLong(){
		  return  scanlong();
		}

	public double nextDouble(){
		  return  scandouble();
		}

	public float nextFloat(){
		  return scanfloat();
		}

	public String next(){
		return scanstring();
	}

	public String nextLine() throws IOException{
		return scan_nextLine();
	}

	public int[] readIntArray(int size)  {
        int[] array = new int[size];
        for (int i = 0; i < size; i++) {
            array[i] = nextInt();
        }
        return array;
    }
}

}

import java.util.Scanner;

public class aaa{
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);

		char[] a = new char[4];
		char[] b = new char[4];

		String str="";
		String str2="";
		for(int i=0; i<4; i++){
			str2+=scn.next();
			if(i==1){
				str=str2;
				str2="";
			}
		}
		if(isSame(str.replace("X", ""),str2.replace("X", "")))
			System.out.println("YES");
		else
			System.out.println("NO");
	}
	static boolean isSame(String s1, String s2){
		int t=0;
		int stt = s2.indexOf(s1.charAt(0));
		String tmp = "";
		if(stt!=0)
			tmp = s2.substring(stt,3) + s2.substring(0,stt);
		else tmp = s2;
		//System.out.println("1. "+tmp);
		if(tmp.equals(s1))
			return true;
		return false;
		/*if(stt!=2){
			tmp = s2.substring(stt+1,3) + s2.substring(0,stt+1);
		}
		else tmp = s2;
		tmp = new StringBuilder(tmp).reverse().toString();
		System.out.println("2. "+tmp);
		if(tmp.equals(s1))
			return true;
		else return false;*/
	}
}

import java.util.Scanner;

public class aaa{
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);

		char[] a = new char[4];
		char[] b = new char[4];

		String str="";
		String str2="";
		for(int i=0; i<4; i++){
			str2+=scn.next();
			if(i==1){
				str=str2;
				str2="";
			}
		}
		if(isSame(str.replace("X", ""),str2.replace("X", "")))
			System.out.println("YES");
		else
			System.out.println("NO");
	}
	static boolean isSame(String s1, String s2){
		int t=0;
		int stt = s2.indexOf(s1.charAt(0));
		String tmp = "";
		if(stt!=0)
			tmp = s2.substring(stt,3) + s2.substring(0,stt);
		else tmp = s2;
		//System.out.println("1. "+tmp);
		if(tmp.equals(s1))
			return true;
		if(stt!=2){
			tmp = s2.substring(stt+1,3) + s2.substring(0,stt+1);
		}
		else tmp = s2;
		tmp = new StringBuilder(tmp).reverse().toString();
		//System.out.println("2. "+tmp);
		if(tmp.equals(s1))
			return true;
		else return false;
	}
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskA solver = new TaskA();
		solver.solve(1, in, out);
		out.close();
	}

	static class TaskA {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			char[][] a = new char[2][];
			char[][] b = new char[2][];
			a[0] = in.next().toCharArray();
			a[1] = in.next().toCharArray();
			b[0] = in.next().toCharArray();
			b[1] = in.next().toCharArray();
			for (int i = 0; i < 4; i++) {
				if (Arrays.equals(a[0], b[0]) && Arrays.equals(a[1], b[1])) {
					out.println("YES");
					return;
				}
				int[][] z = {{0, 0}, {0, 1}, {1, 1}, {1, 0}};
				for (int j = 0; j < 4; j++) {
					if (a[z[j][0]][z[j][1]] == 'X') {
						a[z[j][0]][z[j][1]] = a[z[(j + 1) % 4][0]][z[(j + 1) % 4][1]];
						a[z[(j + 1) % 4][0]][z[(j + 1) % 4][1]] = 'X';
						break;
					}
				}
			}

			out.println("NO");
		}

	}

	static class InputReader {
		final InputStream is;
		final byte[] buf = new byte[1024];
		int pos;
		int size;

		public InputReader(InputStream is) {
			this.is = is;
		}

		public String next() {
			int c = read();
			while (isWhitespace(c))
				c = read();
			StringBuilder sb = new StringBuilder();
			do {
				sb.append((char) c);
				c = read();
			} while (!isWhitespace(c));
			return sb.toString();
		}

		int read() {
			if (size == -1)
				throw new InputMismatchException();
			if (pos >= size) {
				pos = 0;
				try {
					size = is.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (size <= 0)
					return -1;
			}
			return buf[pos++] & 255;
		}

		static boolean isWhitespace(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

	}
}

import java.util.*;
import java.math.*;
import java.io.*;
public final class ccnov1
{
	public static void main(String args [])	throws IOException
	{
		BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw=new PrintWriter(System.out, true);
		String p1[][]=new String [2][2];
		String p2[][]=new String [2][2];
		String p3[][]=new String [2][2];
		String str[]=in.readLine().split("");
		String str2[]=in.readLine().split("");
		String str1[]=in.readLine().split("");
		String str3[]=in.readLine().split("");
		for(int i=0; i<2; i++)
		{

			for(int j=0; j<2; j++)
			{
				if(i==0)
				{p1[i][j]=(str[j]);p2[i][j]=(str1[j]);}
				else
				{p1[i][j]=(str2[j]);p2[i][j]=(str3[j]);}
				p3[i][j]=p1[i][j];
			}
		}
		int chk=0;

		for(int r=0; r<6; r++)
		{
			if(Arrays.deepEquals(p1,p2))
			{
				pw.println("YES");chk=1;break;
			}
			else if(Arrays.deepEquals(p2,p3))
			{
				pw.println("YES");chk=1;break;
			}
			rotateR(p1);
			rotateL(p3);
		}
		if(chk==0)
		{pw.println("NO");}
	}
	public static void rotateL(String p1[][])
	{
		if(p1[0][0].equals("X"))
		{
			swap(0,0,1,0,p1);
		}
		else if(p1[1][0].equals("X"))
		{
			swap(1,0,1,1,p1);
		}
		else if(p1[1][1].equals("X"))
		{
			swap(1,1,0,1,p1);
		}
		else if(p1[0][1].equals("X"))
		{
			swap(0,1,0,0,p1);
		}
	}
	public static void rotateR(String p1[][])
	{
		if(p1[0][0].equals("X"))
		{
			swap(0,0,0,1,p1);
		}
		else if(p1[1][0].equals("X"))
		{
			swap(1,0,0,0,p1);
		}
		else if(p1[1][1].equals("X"))
		{
			swap(1,1,1,0,p1);
		}
		else if(p1[0][1].equals("X"))
		{
			swap(0,1,1,1,p1);
		}
	}
	public static void dis(String p1[][])
	{
		for(int i=0; i<2; i++)
		{
			for(int j=0; j<2; j++)
			{
				System.out.print(p1[i][j]+" ");
			}
			System.out.println();
		}
	}
	public static void swap(int i1, int j1, int i2, int j2, String p1[][])
	{
		String temp=p1[i1][j1];
		p1[i1][j1]=p1[i2][j2];
		p1[i2][j2]=temp;
	}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException  {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String firstLine = br.readLine().trim();
		String SecondLine = br.readLine().trim();
		String thirdLine = br.readLine().trim();
		String fourthLine = br.readLine().trim();

		String Bessie = firstLine + Integer.toString(SecondLine.charAt(1)) + Integer.toString(SecondLine.charAt(0));
		String Elssie = thirdLine + Integer.toString(fourthLine.charAt(1)) + Integer.toString(fourthLine.charAt(0));

		Bessie = Bessie + Bessie;
		Elssie = Elssie + Elssie;

		String msg = "YES";
		int fMatch = 0;
		int fMatch2 = 1;
		if (Bessie.charAt(0) == 'X') {
			fMatch = 1;
			fMatch2 = 2;
		} else {
			if (Bessie.charAt(1) == 'X') {
				fMatch2 = 2;
			}
		}

		for (int i = 0; i < Bessie.length(); i++) {
			if (Elssie.charAt(i) == Bessie.charAt(fMatch)) {
				if (Elssie.charAt(i + 1) != 'X') {
					if (Elssie.charAt(i + 1) != Bessie.charAt(fMatch2)) {
						msg = "NO";
					}
				} else {
					if (Elssie.charAt(i + 2) != Bessie.charAt(fMatch2)) {
						msg = "NO";
					}
				}
			}
		}
		System.out.println(msg);
	}
}

import java.util.Scanner;

/**
 * Author: Destiner
 * Date: 18.03.2016
 */
public class ElimA {
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);

        String lin1 = scanner.nextLine();
        String lin2 = scanner.nextLine();
        String lin3 = scanner.nextLine();
        String lin4 = scanner.nextLine();

        char[][] b1 = new char[2][];
        char[][] b2 = new char[2][];

        b1[0] = new char[2];
        b1[1] = new char[2];
        b2[0] = new char[2];
        b2[1] = new char[2];

        b1[0][0] = lin1.charAt(0);
        b1[0][1] = lin1.charAt(1);
        b1[1][0] = lin2.charAt(0);
        b1[1][1] = lin2.charAt(1);
        b2[0][0] = lin3.charAt(0);
        b2[0][1] = lin3.charAt(1);
        b2[1][0] = lin4.charAt(0);
        b2[1][1] = lin4.charAt(1);

        int type1 = getType(b1);
        int type2 = getType(b2);

        String answer = (type1 == type2) ? "YES" : "NO";
        System.out.print(answer);
    }

    private static int getType(char[][] b) {
        int i;
        if (b[0][0] == 'A') {
            i = 0;
        } else if (b[0][1] == 'A') {
            i = 1;
        } else if (b[1][0] == 'A') {
            i = 2;
        } else {
            i = 3;
        }
        char nextLetter = nextLetter(b, i);
        return nextLetter == 'B' ? 1 : 2;
    }

    private static char nextLetter(char[][] b, int i) {
        char next = getNext(b, i);
        if (next == 'X') {
            return getNext(b, i + 1);
        }
        return next;
    }

    private static char getNext(char[][] b, int i) {
        switch (i % 4) {
            case 0:
                return b[0][1];
            case 1:
                return b[1][1];
            case 2:
                return b[0][0];
            case 3:
                return b[0][1];
        }
        return '\0';
    }
}

import java.io.*;
public class Test{
	public static boolean chk(String[] a1, String[] a2){
		for(int i = 0;i<4;i++){
			if(!a1[i].equals(a2[i]))
				return false;
		}
		return true;
	}
	public static int getX(String[] a){
		for(int i = 0; i<4; i++){
			if(a[i].equals("X"))
				return i;
		}
		return 0;
	}
	public static void main(String[] args)throws IOException{
		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
		String s1 = bf.readLine();
		String s2 = bf.readLine();
		String s = s1+s2;
		String[] arr1 = s.split("");
		s1 = bf.readLine();
		s2 = bf.readLine();
		s = s1+s2;
		String[] arr2 = s.split("");
		String tmp = arr1[3];
		arr1[3] = arr1[2];
		arr1[2] = tmp;
		tmp = arr2[3];
		arr2[3] = arr2[2];
		arr2[2] = tmp;
		boolean c = false;
		int x = getX(arr1);
		for(int i = 0; i<4; i++){
			c = chk(arr1,arr2);
			if(c){
				System.out.println("YES");
				break;
			}
			x = x%4;
		    tmp = arr1[x];
		    arr1[x] = arr1[(x+1)%4];
		    arr1[(x+1)%4] = tmp;
		    x++;
		}
		if(!c)
			System.out.println("NO");
	}
}

import java.io.*;
public class AmityAssessment {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader (new InputStreamReader(System.in));
		int x = -1;
		String s = br.readLine();
		String [] B1 = new String[2];
		B1[0] = s.charAt(0)+"";
		B1[1] = s.charAt(1)+"";
		if(B1[0].equals("X")){
			x=0;
		}else if(B1[1].equals("X")){
			x=1;
		}
		s = br.readLine();
		String [] B2 = new String[2];
		B2[0] = s.charAt(0)+"";
		B2[1] = s.charAt(1)+"";
		if(B2[0].equals("X")){
			x=2;
		}else if(B2[1].equals("X")){
			x=3;
		}
		s = br.readLine();
		String [] A1 = new String[2];
		A1[0] = s.charAt(0)+"";
		A1[1] = s.charAt(1)+"";
		s = br.readLine();
		String [] A2 = new String[2];
		A2[0] = s.charAt(0)+"";
		A2[1] = s.charAt(1)+"";
		int count =1;
		boolean flag = false;
		while(count <= 12){
			count++;
			if(x==0){
				B1[0] = B1[1];

				B1[1] = "X";
			}else if(x==1){
				B1[1] = B2[1];

				B2[1] = "X";
			}else if(x==2){

				B2[0] = B1[0];
				B1[0] = "X";
			}else if(x==3){
				B2[1] = B2[0];
				B2[0] = "X";
			}
			if(B1[0].equals(A1[0]) && B1[1].equals(A1[1]) && B2[0].equals(A2[0]) && B2[1].equals(A2[1])){
				flag = true;
				break;
			}
			if(B1[0].equals("X")){
				x=0;
			}else if(B1[1].equals("X")){
				x=1;
			}else if(B1[0].equals("X")){
				x=0;
			}else if(B1[1].equals("X")){
				x=1;
			}
		}
		if(flag){
			System.out.println("YES");
		}else{
			System.out.println("NO");
		}

	}

}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Tester {
	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		ArrayList<Character> list1 = new ArrayList<Character>(3);
		ArrayList<Character> list2 = new ArrayList<Character>(3);
		String temp = br.readLine();
		int count=0;
		for (int i = 0; i < 2; i++) {
			if(temp.charAt(i)!='X')
			{
				list1.add(count, temp.charAt(i));
			   count++;
			}
		}
		temp = br.readLine();
		for (int i = 0; i < 2; i++) {
			if(temp.charAt(1-i)!='X'){
				list1.add(count, temp.charAt(1-i));
			     count++;
			}
		}
		count=0;
		temp = br.readLine();
		for (int i = 0; i < 2; i++) {
			if(temp.charAt(i)!='X'){
				list2.add(count, temp.charAt(i));
				count++;
			}
		}
		temp = br.readLine();
		for (int i = 0; i < 2; i++)
		if(temp.charAt(1-i)!='X'){
			list2.add(count, temp.charAt(1-i));
			count++;
		}
	//	for(int i=0;i<3;i++)
	//	{
	//		System.out.println(list1.get(i) +" " + list2.get(i));
		//}
	     int flag=1;
	     for(int i=0;i<3;i++)
	      {
	    	  if(list2.get(i++).equals(list1.get(0)))
	    	  {

	    		  for(int j=1;j<3;j++)
	    		  {
	    			  i=i>2 ? 0 : i;
	    			  if(list2.get(i).equals(list1.get(j)))
	    			  i++;
	    			  else
	    			  {
	    				  flag=0;
	    				  break;
	    			  }
	    		  }
	    	  }
	      }
	     if(flag==1)
	    	 System.out.println("YES");
	     else
	    	 System.out.println("NO");

	}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Tester {
	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		ArrayList<Character> list1 = new ArrayList<Character>(3);
		ArrayList<Character> list2 = new ArrayList<Character>(3);
		String temp = br.readLine();
		int count=0;
		for (int i = 0; i < 2; i++) {
			if(temp.charAt(i)!='X')
			{
				list1.add(count, temp.charAt(i));
			   count++;
			}
		}
		temp = br.readLine();
		for (int i = 0; i < 2; i++) {
			if(temp.charAt(1-i)!='X'){
				list1.add(count, temp.charAt(1-i));
			     count++;
			}
		}
		count=0;
		temp = br.readLine();
		for (int i = 0; i < 2; i++) {
			if(temp.charAt(i)!='X'){
				list2.add(count, temp.charAt(i));
				count++;
			}
		}
		temp = br.readLine();
		for (int i = 0; i < 2; i++)
		if(temp.charAt(1-i)!='X'){
			list2.add(count, temp.charAt(1-i));
			count++;
		}
		for(int i=0;i<3;i++)
		{
			System.out.println(list1.get(i) +" " + list2.get(i));
		}
	     int flag=1;
	     System.out.println(list2.get(1));
	     System.out.println(list1.get(0));
	     for(int i=0;i<3;i++)
	      {
	    	 //System.out.println(list1.get(i-1));
	    		//System.out.println(list1.get(i));
	    		if(list2.get(i).equals(list1.get(0)))
	    	  {
	    		//System.out.println(i);

	    		  for(int j=1;j<3;j++)
	    		  {
	    			 i++;
	    			 i=i>2 ? 0 : i;
	    			  if(list2.get(i).equals(list1.get(j)))
	    			  i++;
	    			  else
	    			  {
	    				  flag=0;
	    				  break;
	    			  }
	    		  }
	    	  break;
	    	  }
	      }
	     if(flag==1)
	    	 System.out.println("YES");
	     else
	    	 System.out.println("NO");

	}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Tester {
	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		ArrayList<Character> list1 = new ArrayList<Character>(3);
		ArrayList<Character> list2 = new ArrayList<Character>(3);
		String temp = br.readLine();
		int count=0;
		for (int i = 0; i < 2; i++) {
			if(temp.charAt(i)!='X')
			{
				list1.add(count, temp.charAt(i));
			   count++;
			}
		}
		temp = br.readLine();
		for (int i = 0; i < 2; i++) {
			if(temp.charAt(i)!='X'){
				list1.add(count, temp.charAt(i));
			     count++;
			}
		}
		count=0;
		temp = br.readLine();
		for (int i = 0; i < 2; i++) {
			if(temp.charAt(i)!='X'){
				list2.add(count, temp.charAt(i));
				count++;
			}
		}
		temp = br.readLine();
		for (int i = 0; i < 2; i++)
		if(temp.charAt(i)!='X'){
			list2.add(count, temp.charAt(i));
			count++;
		}
	     int flag=1;
	     for(int i=0;i<3;i++)
	      {
	    	  if(list2.get(i++).equals(list1.get(0)))
	    	  {

	    		  for(int j=1;j<3;j++)
	    		  {
	    			  i=i>2 ? 0 : i;
	    			  if(list2.get(i).equals(list1.get(j)))
	    			  i++;
	    			  else
	    			  {
	    				  flag=0;
	    				  break;
	    			  }
	    		  }
	    	  }
	      }
	     if(flag==1)
	    	 System.out.println("YES");
	     else
	    	 System.out.println("NO");

	}
}

import java.io.*;
import java.util.*;

public class A {
    public static void main(String[] args) throws Exception {
        FastScannerA fs = new FastScannerA();
        PrintWriter out = new PrintWriter(System.out);

        String one = fs.next() + fs.next();
        String two = fs.next() + fs.next();
        int startIndex = 0; char look = two.charAt(0);
        while(one.charAt(startIndex) != look) startIndex++;
        String back = "", forward = "";
        int at = startIndex;
        while(back.length() < two.length()) {
            back += one.charAt(at--);
            if(at < 0) at = one.length()-1;
        }
        at = startIndex;
        while(forward.length() < two.length()) {
            forward += one.charAt(at++);
            if(at == one.length()) at = 0;
        }
        out.println(back.equals(two) || forward.equals(two) ? "YES" : "NO");
        out.close();
    }
}

class FastScannerA {
    BufferedReader br;
    StringTokenizer st;

    public FastScannerA() {
        try	{
            br = new BufferedReader(new InputStreamReader(System.in));
            st = new StringTokenizer("");
        } catch (Exception e){e.printStackTrace();}
    }

    public String next() {
        if (st.hasMoreTokens())	return st.nextToken();
        try {st = new StringTokenizer(br.readLine());}
        catch (Exception e) {e.printStackTrace();}
        return st.nextToken();
    }

    public int nextInt() {return Integer.parseInt(next());}

    public long nextLong() {return Long.parseLong(next());}

    public double nextDouble() {return Double.parseDouble(next());}

    public String nextLine() {
        String line = "";
        try {line = br.readLine();}
        catch (Exception e) {e.printStackTrace();}
        return line;
    }

    public Integer[] nextIntegerArray(int n) {
        Integer[] a = new Integer[n];
        for(int i = 0; i < n; i++) a[i] = nextInt();
        return a;
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for(int i = 0; i < n; i++) a[i] = nextInt();
        return a;
    }

    public char[] nextCharArray() {
        return nextLine().toCharArray();
    }
}

import java.io.*;
import java.util.*;
/*
 * This file was created by ayush in attempt to solve the problem problems
 */
public class main {
    public void solve(String[][] initial,String[][] fin, PrintWriter out) {
	int finX=0;
	int finY=0;
	//out.println(initial[0][1]);
	for(int i=0;i<2;i++){
		for(int j=0;j<2;j++){
			if(fin[i][j].equals("X")){
				finX=i;
				finY=j;
			}
		}
	}
	DEBUG.DebugVariable("finX",finX);
	DEBUG.DebugVariable("finY",finY);
	int initX=0;
	int initY=0;
	String[][] temp = new String[2][2];
 	for(int i=0;i<2;i++){
		for(int j=0;j<2;j++){
			temp[i][j]=initial[i][j];
			if(initial[i][j].equals("X")){
				initX=i;
				initY=j;
			}
		}
	}
	DEBUG.DebugVariable("initX",initX);
	DEBUG.DebugVariable("initY",initY);
	int curX=initX;
	int curY=initY;

	while(curX!=finX ||  curY != finY){
		if(curX==1 && curY==0){
			temp[curX][curY] = temp[1][1];
			temp[1][1]="X";
			curX = 1;
			curY =1;
		}else if(curX==0 && curY==0){
			temp[curX][curY]= temp[1][0];
			temp[1][0]="X";
			curX=1;
			curY=0;
		}else if(curX==1 && curY==1){
			temp[curX][curY] = temp[0][1];
			temp[0][1]="X";
			curX=0;
			curY=1;
		}else if(curX==0 && curY==1){
			temp[curX][curY]=temp[0][0];
			temp[0][0]="X";
			curX=0;
			curY=0;
		}

	}
	DEBUG.DebugVariable("curX",curX);
	DEBUG.DebugVariable("curY",curX);
	boolean ans=true;
	for(int i=0;i<2;i++){
		for(int j=0;j<2;j++){
			if(!fin[i][j].equals(temp[i][j])){
				ans=false;
			}
		}

	}

	if(ans){out.println("YES");return;}

	 curX=initX;
	 curY=initY;

	while(curX!=finX || curY != finY){
		if(curX==1 && curY==0){
			initial[curX][curY] = initial[0][0];
			initial[0][0]="X";
			curX = 0;
			curY =0;
		}else if(curX==0 && curY==0){
			initial[curX][curY]= initial[0][1];
			initial[0][1]="X";
			curX=0;
			curY=1;
		}else if(curX==1 && curY==1){
			initial[curX][curY] = initial[1][0];
			initial[1][0] = "X";
			curX=1;
			curY=0;
		}else if(curX==0 && curY==1){
			initial[curX][curY]=initial[1][1];
			initial[1][1]="X";
			curX=1;
			curY=1;
		}

	}
	ans=true;
	for(int i=0;i<2;i++){
		for(int j=0;j<2;j++){
//			out.println(initial[i][j]);
			if(!fin[i][j].equals(initial[i][j])){
				ans=false;
			}
		}

	}

	if(ans){out.println("YES");}else{out.println("NO");}
	//String[][] temp = new String[2][2];

    }

    public static void main(String[] args) throws IOException {

        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
        //int n = Integer.parseInt(in.readLine());
        String[][] initial = IOUtils.read2DStringArray(in,2,2,"");
	String[][] fin =  IOUtils.read2DStringArray(in,2,2,"");
        Date t1 = new Date();
        main solver = new main();
	//for(int i=0;i<n;i++){
        solver.solve(initial,fin, out);
        out.flush();
	//}
        Date t2 = new Date();
        System.err.println(String.format("Your program took %f seconds", (t2.getTime() - t1.getTime()) / 1000.0));
        out.close();

    }

    static class IOUtils {

        public static int[] readIntArray(Scanner in, int size) {
            int[] array = new int[size];
            for (int i = 0; i < size; i++)
                array[i] = in.nextInt();
            return array;
        }

        public static String[] readStringArray(Scanner in, int size) {
            String[] array = new String[size];
            for (int i = 0; i < size; i++)
                array[i] = in.nextLine();
            return array;
        }

        public static int[] readLinearIntArray(Scanner in, int size) {
            //in.nextLine();
            String[] arr = in.nextLine().split(" ");
            int[] array = new int[size];
            for (int i = 0; i < size; i++)
                array[i] = Integer.parseInt(arr[i]);
            return array;
        }

        public static int[] readLinearIntArray(BufferedReader in) throws IOException {
            //in.nextLine();
            String[] arr = in.readLine().split(" ");
            int[] array = new int[arr.length];
            for (int i = 0; i < arr.length; i++)
                array[i] = Integer.parseInt(arr[i]);
            return array;
        }

        public static Double[] readLinearDoubleArray(BufferedReader in) throws IOException {
            //in.nextLine();
            String[] arr = in.readLine().split(" ");
            Double[] array = new Double[arr.length];
            for (int i = 0; i < arr.length; i++)
                array[i] = Double.parseDouble(arr[i]);
            return array;
        }

        public static String[] convert(int[] from) {
            String[] to = new String[from.length];
            for (int i = 0; i < to.length; i++) to[i] = String.valueOf(from[i]);
            return to;
        }

        public static int[] convert(String[] from) {
            int[] to = new int[from.length];
            for (int i = 0; i < to.length; i++) to[i] = Integer.parseInt(from[i]);
            return to;
        }

        public static int[][] read2DIntArray(BufferedReader in, int rows, int columns, String seprator) throws IOException {
            int[][] array = new int[rows][columns];
            for (int i = 0; i < rows; i++) {
                array[i] = convert(in.readLine().split(seprator));
            }
            return array;
        }

        public static String[][] read2DStringArray(BufferedReader in, int rows, int columns, String seprator) throws IOException {
            String[][] array = new String[rows][columns];
            for (int i = 0; i < rows; i++) {
                array[i] = in.readLine().split(seprator);
            }
            return array;
        }
    }

    static class DEBUG {
        public static void DebugInfo(String disp) {
            System.err.println("DEBUG Info: " + disp);
        }

        public static void DebugVariable(String variable, String value) {
            System.err.println("DEBUG Info: " + variable + " => " + value);
        }

        public static void DebugVariable(String variable, int value) {
            System.err.println("DEBUG Info: " + variable + " => " + value);
        }

        public static void DebugVariable(String variable, long value) {
            System.err.println("DEBUG Info: " + variable + " => " + value);
        }

        public static void DebugArray(int[] value) {
            for (int i = 0; i < value.length; i++) {

                System.err.println("DEBUG Info: " + i + " => " + value[i]);
            }
        }

    }

}

import java.util.*;
import java.io.*;

//DONT FORGET TO CHANGE CLASS NAME!
public class AmityAssesment {
    /*
    This could be a hard ish problem where we have to search all possible
    perumtations. However if we recognize that we can only rotate around the board
    Then we figure out that we just need to ensure the characters all come in the same order
    That is, can we cycle one string to get the other
    We can do this by creating the string in the CCW order
    we want to check the order 1 2 3 4 ignoring the X
    Let the upper left be 1
    we will call lower left 2, lower right 3, and upper right 4
    We create the string corresponding to 1 2 3 4 for each input
    and then remove X
    and check if one string is a 1-shift permuatation of the other

    */
    static boolean testing = false; //change to false on submission
    static String name = "CodeForcesTemplate"; // insert the class name here
    public static void main(String[] args) throws IOException {
        Scanner input;
        PrintWriter writer;
        if(testing){input = new Scanner(new FileReader(name+".in"));writer = new PrintWriter(name+".out");}else{input = new Scanner(System.in);writer = new PrintWriter(System.out);}
        //Declare Variables
        StringTokenizer tokenizer;
        String s1, s2;
        char a, b;
        //read input, execute program
        tokenizer = new StringTokenizer(input.nextLine());
        s1 = tokenizer.nextToken();
        a = s1.charAt(0);
        b = s1.charAt(1);
        tokenizer = new StringTokenizer(input.nextLine());
        s1 = a + tokenizer.nextToken() + b;
        s1 = s1.replace("X","");
        s1 = s1.substring(s1.indexOf("A")) + s1.substring(0, s1.indexOf("A"));

        tokenizer = new StringTokenizer(input.nextLine());
        s2 = tokenizer.nextToken();
        a = s2.charAt(0);
        b = s2.charAt(1);
        tokenizer = new StringTokenizer(input.nextLine());
        s2 = a + tokenizer.nextToken() + b;
        s2 = s2.replace("X","");
        s2 = s2.substring(s2.indexOf("A")) + s2.substring(0, s2.indexOf("A"));
        writer.println(s1+" "+s2);
        if(s1.equals(s2)){writer.println("YES");}
        else{writer.println("NO");}

        writer.close();
        input.close();
    }

    }//Class Close Bracket

import java.util.*;
import java.io.*;

//DONT FORGET TO CHANGE CLASS NAME!
public class AmityAssesment {
    /*
    This could be a hard ish problem where we have to search all possible
    perumtations. However if we recognize that we can only rotate around the board
    Then we figure out that we just need to ensure the characters all come in the same order
    That is, can we cycle one string to get the other
    We can do this by creating the string in the CCW order
    we want to check the order 1 2 3 4 ignoring the X
    Let the upper left be 1
    we will call lower left 2, lower right 3, and upper right 4
    We create the string corresponding to 1 2 3 4 for each input
    and then remove X
    and check equality

    */
    static boolean testing = false; //change to false on submission
    static String name = "CodeForcesTemplate"; // insert the class name here
    public static void main(String[] args) throws IOException {
        Scanner input;
        PrintWriter writer;
        if(testing){input = new Scanner(new FileReader(name+".in"));writer = new PrintWriter(name+".out");}else{input = new Scanner(System.in);writer = new PrintWriter(System.out);}
        //Declare Variables
        StringTokenizer tokenizer;
        String s1, s2;
        char a, b;
        //read input, execute program
        tokenizer = new StringTokenizer(input.nextLine());
        s1 = tokenizer.nextToken();
        a = s1.charAt(0);
        b = s1.charAt(1);
        tokenizer = new StringTokenizer(input.nextLine());
        s1 = a + tokenizer.nextToken() + b;
        s1 = s1.replace("X","");

        tokenizer = new StringTokenizer(input.nextLine());
        s2 = tokenizer.nextToken();
        a = s2.charAt(0);
        b = s2.charAt(1);
        tokenizer = new StringTokenizer(input.nextLine());
        s2 = a + tokenizer.nextToken() + b;
        s2 = s2.replace("X","");
        if(s1.equals(s2)){writer.println("YES");}
        else{writer.println("NO");}

        writer.close();
        input.close();
    }

    }//Class Close Bracket

import java.util.*;
import java.io.*;

//DONT FORGET TO CHANGE CLASS NAME!
public class AmityAssesment {
    /*
    This could be a hard ish problem where we have to search all possible
    perumtations. However if we recognize that we can only rotate around the board
    Then we figure out that we just need to ensure the characters all come in the same order
    That is, can we cycle one string to get the other
    We can do this by creating the string in the CCW order
    we want to check the order 1 2 3 4 ignoring the X
    Let the upper left be 1
    we will call lower left 2, lower right 3, and upper right 4
    We create the string corresponding to 1 2 3 4 for each input
    and then remove X
    and check equality

    */
    static boolean testing = false; //change to false on submission
    static String name = "CodeForcesTemplate"; // insert the class name here
    public static void main(String[] args) throws IOException {
        Scanner input;
        PrintWriter writer;
        if(testing){input = new Scanner(new FileReader(name+".in"));writer = new PrintWriter(name+".out");}else{input = new Scanner(System.in);writer = new PrintWriter(System.out);}
        //Declare Variables
        StringTokenizer tokenizer;
        String s1, s2;
        //read input, execute program
        tokenizer = new StringTokenizer(input.nextLine());
        s1 = tokenizer.nextToken();
        tokenizer = new StringTokenizer(input.nextLine());
        s1 = s1.charAt(0) + tokenizer.nextToken() +s1.charAt(1);
        s1 = s1.replace("X","");

        tokenizer = new StringTokenizer(input.nextLine());
        s2 = tokenizer.nextToken();
        tokenizer = new StringTokenizer(input.nextLine());
        s2 = s2.charAt(0) + tokenizer.nextToken() + s2.charAt(1);
        s2 = s2.replace("X","");
        if(s1.equals(s2)){writer.println("YES");}
        else{writer.println("NO");}

        writer.close();
        input.close();
    }

    }//Class Close Bracket

import java.util.*;
import java.io.*;

//DONT FORGET TO CHANGE CLASS NAME!
public class AmityAssesment {
    /*
    This could be a hard ish problem where we have to search all possible
    perumtations. However if we recognize that we can only rotate around the board
    Then we figure out that we just need to ensure the characters all come in the same order
    That is, can we cycle one string to get the other
    We can do this by creating the string in the CCW order
    we want to check the order 1 2 3 4 ignoring the X
    Let the upper left be 1
    we will call lower left 2, lower right 3, and upper right 4
    We create the string corresponding to 1 2 3 4 for each input
    and then remove X
    and check if one string is a 1-shift permuatation of the other

    */
    static boolean testing = false; //change to false on submission
    static String name = "CodeForcesTemplate"; // insert the class name here
    public static void main(String[] args) throws IOException {
        Scanner input;
        PrintWriter writer;
        if(testing){input = new Scanner(new FileReader(name+".in"));writer = new PrintWriter(name+".out");}else{input = new Scanner(System.in);writer = new PrintWriter(System.out);}
        //Declare Variables
        StringTokenizer tokenizer;
        String s1, s2;
        char a, b;
        //read input, execute program
        tokenizer = new StringTokenizer(input.nextLine());
        s1 = tokenizer.nextToken();
        a = s1.charAt(0);
        b = s1.charAt(1);
        tokenizer = new StringTokenizer(input.nextLine());
        s1 = a + tokenizer.nextToken() + b;
        s1 = s1.replace("X","");
        s1 = s1.substring(s1.indexOf("A")) + s1.substring(0, s1.indexOf("A"));

        tokenizer = new StringTokenizer(input.nextLine());
        s2 = tokenizer.nextToken();
        a = s2.charAt(0);
        b = s2.charAt(1);
        tokenizer = new StringTokenizer(input.nextLine());
        s2 = a + tokenizer.nextToken() + b;
        s2 = s2.replace("X","");
        s2 = s2.substring(s2.indexOf("A")) + s1.substring(0, s2.indexOf("A"));

        if(s1.equals(s2)){writer.println("YES");}
        else{writer.println("NO");}

        writer.close();
        input.close();
    }

    }//Class Close Bracket

import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;

public class SlidingPuzzles {

	public static void main(String[] args) throws Exception {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw = new PrintWriter(new BufferedOutputStream(System.out));

		ArrayList<String> slider1 = clockwiseArrangement(br);
		ArrayList<String> slider2 = clockwiseArrangement(br);

		slider1.remove("X");
		slider2.remove("X");

		slider2 = rotate(slider2, (slider2.indexOf("A") - slider1.indexOf("A") + 4) % 4);

		if(Arrays.equals(slider1.toArray(), slider2.toArray())) {
			pw.write("YES");
		} else {
			pw.write("NO");
		}

		//System.out.println(Arrays.toString(slider1.toArray()));
		//System.out.println(Arrays.toString(slider2.toArray()));

		br.close();
		pw.close();
	}

	public static ArrayList<String> clockwiseArrangement(BufferedReader br) throws Exception {
		ArrayList<String> circle = new ArrayList<>();
		String line;

		line = br.readLine();
		circle.add(line.split("")[0]);
		circle.add(line.split("")[1]);
		line = br.readLine();
		circle.add(line.split("")[1]);
		circle.add(line.split("")[0]);

		return circle;
	}

	public static ArrayList<String> rotate(ArrayList<String> circle, int shift) {
		ArrayList<String> newCircle = new ArrayList<>();

		for(int i = 0; i < circle.size(); i++) {
			newCircle.add(circle.get((i + shift + circle.size()) % circle.size()));
		}

		return newCircle;
	}

}

//package crash_course.chapter1;

import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;

public class SlidingPuzzles {

	public static void main(String[] args) throws Exception {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw = new PrintWriter(new BufferedOutputStream(System.out));

		ArrayList<String> slider1 = clockwiseArrangement(br);
		ArrayList<String> slider2 = clockwiseArrangement(br);

		slider1.remove("X");
		slider2.remove("X");

		//System.out.println(Arrays.toString(slider1.toArray()));
		//System.out.println(Arrays.toString(slider2.toArray()));

		slider2 = rotate(slider2, slider1.indexOf("A") - slider2.indexOf("A") + slider1.size());

		//System.out.println(Arrays.toString(slider2.toArray()));

		if(Arrays.equals(slider1.toArray(), slider2.toArray())) {
			pw.write("YES");
		} else {
			pw.write("NO");
		}

		//System.out.println(Arrays.toString(slider1.toArray()));
		//System.out.println(Arrays.toString(slider2.toArray()));

		br.close();
		pw.close();
	}

	public static ArrayList<String> clockwiseArrangement(BufferedReader br) throws Exception {
		ArrayList<String> circle = new ArrayList<>();
		String line;

		line = br.readLine();
		circle.add(line.split("")[0]);
		circle.add(line.split("")[1]);
		line = br.readLine();
		circle.add(line.split("")[1]);
		circle.add(line.split("")[0]);

		return circle;
	}

	public static ArrayList<String> rotate(ArrayList<String> circle, int shift) {
		System.out.println("SHIFT:" + shift);
		for(int i = 0; i < shift; i++) {
			circle.add(0, circle.get(circle.size() - 1));
			circle.remove(circle.size()-1);
		}

		return circle;
	}

}

import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;

public class SlidingPuzzles {

	public static void main(String[] args) throws Exception {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw = new PrintWriter(new BufferedOutputStream(System.out));

		ArrayList<String> slider1 = clockwiseArrangement(br);
		ArrayList<String> slider2 = clockwiseArrangement(br);

		slider1.remove("X");
		slider2.remove("X");

		slider2 = rotate(slider2, (slider2.indexOf("A") - slider1.indexOf("A") + 4) % 4);

		if(Arrays.equals(slider1.toArray(), slider2.toArray())) {
			pw.write("YES");
		} else {
			pw.write("NO");
		}

		//System.out.println(Arrays.toString(slider1.toArray()));
		//System.out.println(Arrays.toString(slider2.toArray()));

		br.close();
		pw.close();
	}

	public static ArrayList<String> clockwiseArrangement(BufferedReader br) throws Exception {
		ArrayList<String> circle = new ArrayList<>();
		String line;

		line = br.readLine();
		circle.add(line.split("")[0]);
		circle.add(line.split("")[1]);
		line = br.readLine();
		circle.add(line.split("")[1]);
		circle.add(line.split("")[0]);

		return circle;
	}

	public static ArrayList<String> rotate(ArrayList<String> circle, int shift) {
		ArrayList<String> newCircle = new ArrayList<>();

		for(int i = 0; i < circle.size(); i++) {
			newCircle.add(circle.get((i + shift + 4) % circle.size()));
		}

		return newCircle;
	}

}

import java.util.Scanner;

public class SlidingPuzzles
{
    public static void main(String[] args)
    {
        Scanner input = new Scanner(System.in);
        String in;
        String out = "";
        boolean quit = false;
        char temp;
        char[] first = new char[4];
        char[] second = new char[4];

        for (int i = 0; i < 2; i++)
        {
            in = input.nextLine();
            first[i] = in.charAt(0);
            first[i+1] = in.charAt(1);
        }

        for (int i = 0; i < 2; i++)
        {
            in = input.nextLine();
            second[i] = in.charAt(0);
            second[i+1] = in.charAt(1);
        }

        for (int i = 0; i < 4; i++)
        {
            for (int y = 0; y < 4; y++)
            {
                if (first[i] != second[i])
                {
                    out = "NO";

                    temp = first[3];

                    first[3] = first[2];
                    first[2] = first[1];
                    first[1] = first[0];
                    first[0] = temp;

                    break;
                }
                else
                {
                    if (y == 3)
                    {
                        quit = true;
                        out = "YES";
                    }
                }
            }

            if (quit)
            {
                break;
            }
        }

        System.out.println(out);
    }
}

import java.io.InputStreamReader;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.InputStream;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author Erasyl Abenov
 *
 *
 */
public class Main {
    public static void main(String[] args) throws IOException {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
            try (PrintWriter out = new PrintWriter(outputStream)) {
                TaskB solver = new TaskB();
                solver.solve(1, in, out);
            }
    }
}
class TaskB {
    public void solve(int testNumber, InputReader in, PrintWriter out){
        String a = in.next() + (new StringBuilder(in.next())).reverse().toString();
        String b = in.next() + (new StringBuilder(in.next())).reverse().toString();
        a = a.replace("X", "");
        b = b.replace("X", "");
        if((a + a).indexOf(b) > 0)
            out.println("YES");
        else out.println("NO");
    }
}

class InputReader {
    private final BufferedReader reader;
    private StringTokenizer tokenizer;
    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream));
        tokenizer = null;
    }

    public String nextLine() {
        try {
            return reader.readLine();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(nextLine());
        }
        return tokenizer.nextToken();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }
    public BigInteger nextBigInteger(){
        return new BigInteger(next());
    }
    public long nextLong() {
        return Long.parseLong(next());
    }
    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

import java.io.InputStreamReader;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.InputStream;
import java.math.BigInteger;
import java.util.Arrays;
/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author Erasyl Abenov
 *
 *
 */
public class Main {
    public static void main(String[] args) throws IOException {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
            try (PrintWriter out = new PrintWriter(outputStream)) {
                TaskB solver = new TaskB();
                solver.solve(1, in, out);
            }
    }
}
class TaskB {
    public void solve(int testNumber, InputReader in, PrintWriter out){
        String a = in.next();
        StringBuilder sb1 = new StringBuilder(in.next());
        String c = in.next();
        StringBuilder sb2 = new StringBuilder(in.next());
        a = a + sb1.reverse().toString();
        c = c + sb2.reverse().toString();
        if(ss(a, c) || st(a, c)) out.println("YES");
        else out.println("NO");
    }
    boolean ss(String s, String t){
        for(int i = 0; i < 5; ++i){
            if(s.equals(t)) return true;
            int k = s.indexOf("X");
            char c[] = s.toCharArray();
            char tmp = c[k];
            c[k] = c[(k + 1)%4];
            c[(k + 1)%4] = tmp;
            s = "";
            for(int j = 0; j < 4; ++j)
                s = s + c[j];
        }
        return false;
    }
    boolean st(String s, String t){
        for(int i = 0; i < 5; ++i){
            if(s.equals(t)) return true;
            int k = s.indexOf("X");
            char c[] = s.toCharArray();
            int nn = k - 1;
            if(nn < 0) nn = 3;
            char tmp = c[k];
            c[k] = c[nn];
            c[nn] = tmp;
            s = "";
            for(int j = 0; j < 4; ++j)
                s = s + c[j];
        }
        return false;
    }
}

class InputReader {
    private final BufferedReader reader;
    private StringTokenizer tokenizer;
    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream));
        tokenizer = null;
    }

    public String nextLine() {
        try {
            return reader.readLine();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(nextLine());
        }
        return tokenizer.nextToken();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }
    public BigInteger nextBigInteger(){
        return new BigInteger(next());
    }
    public long nextLong() {
        return Long.parseLong(next());
    }
    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

import java.io.InputStreamReader;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.InputStream;
import java.math.BigInteger;
import java.util.Arrays;
/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author Erasyl Abenov
 *
 *
 */
public class Main {
    public static void main(String[] args) throws IOException {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
            try (PrintWriter out = new PrintWriter(outputStream)) {
                TaskB solver = new TaskB();
                solver.solve(1, in, out);
            }
    }
}
class TaskB {
    public void solve(int testNumber, InputReader in, PrintWriter out){
        String s = in.next();
        StringBuilder sb = new StringBuilder(in.next());
        String c = in.next();
        StringBuilder sb1 = new StringBuilder(in.next());
        s = s + sb.reverse().toString();
        c = c + sb1.reverse().toString();
        int x = s.indexOf("X");
        int y = c.indexOf("X");
        int cnt = 0;
        for(int i = 0; i < 4; ++i)
            if(s.charAt(i) == c.charAt(i)) cnt++;
        if(s.charAt(y) == c.charAt(x) && cnt > 1) out.println("YES");
        else out.println("NO");
    }
}

class InputReader {
    private final BufferedReader reader;
    private StringTokenizer tokenizer;
    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream));
        tokenizer = null;
    }

    public String nextLine() {
        try {
            return reader.readLine();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(nextLine());
        }
        return tokenizer.nextToken();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }
    public BigInteger nextBigInteger(){
        return new BigInteger(next());
    }
    public long nextLong() {
        return Long.parseLong(next());
    }
    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

import java.io.InputStreamReader;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.InputStream;
import java.math.BigInteger;
import java.util.Arrays;
/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author Erasyl Abenov
 *
 *
 */
public class Main {
    public static void main(String[] args) throws IOException {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
            try (PrintWriter out = new PrintWriter(outputStream)) {
                TaskB solver = new TaskB();
                solver.solve(1, in, out);
            }
    }
}
class TaskB {
    public void solve(int testNumber, InputReader in, PrintWriter out){
        String a = in.next() + in.next();
        String b = in.next() + in.next();
        int cnt = 0;
        for(int i = 0; i < 4; ++i){
            if(a.charAt(i) == b.charAt(i))
                cnt++;
        }
        if(cnt > 1) out.println("YES");
        else out.println("NO");
    }
}

class InputReader {
    private final BufferedReader reader;
    private StringTokenizer tokenizer;
    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream));
        tokenizer = null;
    }

    public String nextLine() {
        try {
            return reader.readLine();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(nextLine());
        }
        return tokenizer.nextToken();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }
    public BigInteger nextBigInteger(){
        return new BigInteger(next());
    }
    public long nextLong() {
        return Long.parseLong(next());
    }
    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

import java.io.InputStreamReader;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.InputStream;
import java.math.BigInteger;
import java.util.Arrays;
/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author Erasyl Abenov
 *
 *
 */
public class Main {
    public static void main(String[] args) throws IOException {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
            try (PrintWriter out = new PrintWriter(outputStream)) {
                TaskB solver = new TaskB();
                solver.solve(1, in, out);
            }
    }
}
class TaskB {
    public void solve(int testNumber, InputReader in, PrintWriter out){
        String s = in.next();
        StringBuilder sb = new StringBuilder(in.next());
        String c = in.next();
        StringBuilder sb1 = new StringBuilder(in.next());
        s = s + sb.reverse().toString();
        c = c + sb1.reverse().toString();
        int x = s.indexOf("X");
        int y = c.indexOf("X");
        if(s.charAt(y) == c.charAt(x)) out.println("YES");
        else out.println("NO");
    }
}

class InputReader {
    private final BufferedReader reader;
    private StringTokenizer tokenizer;
    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream));
        tokenizer = null;
    }

    public String nextLine() {
        try {
            return reader.readLine();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(nextLine());
        }
        return tokenizer.nextToken();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }
    public BigInteger nextBigInteger(){
        return new BigInteger(next());
    }
    public long nextLong() {
        return Long.parseLong(next());
    }
    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

import java.util.*;
import java.io.*;

public class A645
{

	public static void main(String[] args) throws Exception
	{
		Scanner in = new Scanner(System.in);
		String a1 = in.next();
        String a2 = in.next();
        String b1 = in.next();
        String b2 = in.next();

        String s1 = concat(a1, a2);
        String s2 = concat(b1, b2);

        for (int i = 0; i < s1.length(); i++) {
            if (s1.charAt(i) == s2.charAt(i)) {
                System.out.println("NO");
                return;
            }
        }
        System.out.println("YES");

	}

    public static String concat(String s1, String s2) {
        String ans = "";
        for (int i = 0; i < s1.length(); i++) {
            if (s1.charAt(i) != 'X') {
                ans += s1.charAt(i)+"";
            }
        }
        for (int i = s2.length()-1; i >= 0; i--) {
            if (s2.charAt(i) != 'X') {
                ans += s2.charAt(i)+"";
            }
        }
        return ans;
    }
}

import java.util.*;
public class solve {

	public static void main(String[] args){
		Scanner input = new Scanner(System.in);
		String x = input.next();
		String x1 = input.next();
		String y = input.next();
		String y1 = input.next();
		String one = "";
		if(x.charAt(1)!='X') one+=x.charAt(1);
		if(x.charAt(0)!='X') one+=x.charAt(0);if(x1.charAt(0)!='X') one+=x1.charAt(0);if(x1.charAt(1)!='X') one+=x1.charAt(1);
		String two ="";
		if(y.charAt(1)!='X') two+=y.charAt(1);
		if(y.charAt(0)!='X') two+=y.charAt(0);if(y1.charAt(0)!='X') two+=y1.charAt(0);if(y1.charAt(1)!='X') two+=y1.charAt(1);

	String pos1 = one.substring(2)+one.charAt(0)+one.charAt(1);
	String pos2 = pos1.substring(2)+pos1.charAt(0)+pos1.charAt(1);
	String pos3 = pos2.substring(2)+pos2.charAt(0)+pos2.charAt(1);
	if(one.equals(two)||one.equals(pos1)||one.equals(pos2)||one.equals(pos3))System.out.print("YES");else System.out.print("NO");

}
}

import java.util.*;
public class solve {

	public static void main(String[] args){
		Scanner input = new Scanner(System.in);
		String x = input.next();
		String x1 = input.next();
		String y = input.next();
		String y1 = input.next();
		String one = "";
		if(x.charAt(1)!='X') one+=x.charAt(1);
		if(x.charAt(0)!='X') one+=x.charAt(0);if(x1.charAt(0)!='X') one+=x1.charAt(0);if(x1.charAt(1)!='X') one+=x1.charAt(1);
		String two ="";
		if(y.charAt(1)!='X') two+=y.charAt(1);
		if(y.charAt(0)!='X') two+=y.charAt(0);if(y1.charAt(0)!='X') two+=y1.charAt(0);if(y1.charAt(1)!='X') two+=y1.charAt(1);

	String pos1 = one.substring(2)+one.charAt(1)+one.charAt(0);
	String pos2 = pos1.substring(2)+pos1.charAt(0)+pos1.charAt(1);
	String pos3 = pos2.substring(2)+pos2.charAt(0)+pos2.charAt(1);
	if(one.equals(two)||one.equals(pos1)||one.equals(pos2)||one.equals(pos3))System.out.print("YES");else System.out.print("NO");

}
}

//package com.company;

import java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.*;

public class Main {
    public static void main(String[] args) throws IOException {
        new Main().run();
    }

    public void run() throws IOException {
        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        char[] c1 = new char[4];
        char[] c2 = new char[4];
        String s = in.next();
        int k = 0;
        for(int i = 0; i < 2; i++)
            if(s.charAt(i) != 'X') c1[k++] = s.charAt(i);
        s = in.next();
        for(int i = 1; i >= 0; i--)
            if(s.charAt(i) != 'X') c1[k++] = s.charAt(i);
        k = 0;
        s = in.next();
        for(int i = 0; i < 2; i++)
            if(s.charAt(i) != 'X') c2[k++] = s.charAt(i);
        s = in.next();
        for(int i = 1; i >= 0; i--)
            if(s.charAt(i) != 'X') c2[k++] = s.charAt(i);
        int k1, k2;
        for(int i = 0; i < 4; i++){
            if (c1[i] == 'A') k1 = i;
            if (c2[i] == 'A') k2 = i;
        }
        k1 = 0;
        k2 = 0;
        if (k1 == 2) k1 = 0;
        if (k2 == 2) k2 = 0;
        if (c1[k1+1] == c2[k2+1]) out.print("YES");
        else out.print("NO");
        out.close();
    }
}

//package com.company;

import java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.*;

public class Main {
    public static void main(String[] args) throws IOException {
        new Main().run();
    }

    public void run() throws IOException {
        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        char[] c1 = new char[4];
        char[] c2 = new char[4];
        String s = in.next();
        int k = 0;
        for(int i = 0; i < 2; i++)
            if(s.charAt(i) != 'X') c1[k++] = s.charAt(i);
        s = in.next();
        for(int i = 1; i >= 0; i--)
            if(s.charAt(i) != 'X') c1[k++] = s.charAt(i);
        k = 0;
        for(int i = 0; i < 2; i++)
            if(s.charAt(i) != 'X') c2[k++] = s.charAt(i);
        s = in.next();
        for(int i = 1; i >= 0; i--)
            if(s.charAt(i) != 'X') c2[k++] = s.charAt(i);
        int k1, k2;
        for(int i = 0; i < 4; i++){
            if (c1[i] == 'A') k1 = i;
            if (c2[i] == 'A') k2 = i;
        }
        k1 = 0;
        k2 = 0;
        if (k1 == 2) k1 = 0;
        if (k2 == 2) k2 = 0;
        if (c1[k1+1] == c2[k2+1]) out.print("YES");
        else out.print("NO");
        out.close();
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class ProblemA {
	public static void main(String[] args) {
		InputReader in = new InputReader();
		PrintWriter out = new PrintWriter(System.out);

		new ProblemA().solve(in, out);

		out.close();
	}

	public void solve(InputReader in, PrintWriter out) {
		String s1 = in.next();
		String s2 = in.next();

		char[] a = new char[3];

		int i = 0;

		if (s1.charAt(0) != 'X') {
			a[i++] = s1.charAt(0);
		}

		if (s1.charAt(1) != 'X') {
			a[i++] = s1.charAt(1);
		}

		if (s2.charAt(1) != 'X') {
			a[i++] = s2.charAt(1);
		}

		if (s2.charAt(0) != 'X') {
			a[i++] = s2.charAt(0);
		}

		String s3 = in.next();
		String s4 = in.next();

		char[] b = new char[3];

		i = 0;

		if (s3.charAt(0) != 'X') {
			b[i++] = s3.charAt(0);
		}

		if (s3.charAt(1) != 'X') {
			b[i++] = s3.charAt(1);
		}

		if (s4.charAt(1) != 'X') {
			b[i++] = s4.charAt(1);
		}

		if (s4.charAt(0) != 'X') {
			b[i++] = s4.charAt(0);
		}

		for (int j = 0; j < 3; j++) {

			// shift b by j
			char[] c = new char[3];
			for (int k = 0; k < 3; k++) {
				c[(k + j) % 3] = b[k];
			}

			b = c;

			boolean eq = true;

			for (int k = 0; k < 3; k++) {
				if (a[k] != b[k]) {
					eq = false;
				}
			}

			if (eq) {
				out.println("YES");

				return;
			}
		}

		out.println("NO");
	}

	static class InputReader {
		public BufferedReader br;
		public StringTokenizer st;

		public InputReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return st.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}
}

import java.io.*;
import java.util.*;
public class Main implements Runnable{

    private void solve()throws IOException{
        String a="";
        String b="";
        String s[]=new String[4];
        for(int i=0;i<4;i++)
            s[i]=nextLine();
        if(s[0].charAt(0)!='X')
            a+=s[0].charAt(0);
        if(s[0].charAt(1)!='X')
            a+=s[0].charAt(1);
        if(s[1].charAt(1)!='X')
            a+=s[1].charAt(1);
        if(s[1].charAt(0)!='X')
            a+=s[1].charAt(0);

        if(s[2].charAt(0)!='X')
            b+=s[2].charAt(0);
        if(s[2].charAt(1)!='X')
            b+=s[2].charAt(1);
        if(s[3].charAt(1)!='X')
            b+=s[3].charAt(1);
        if(s[3].charAt(0)!='X')
            b+=s[3].charAt(0);
        while(b.charAt(0)!='A')
            b=b.substring(1,b.length())+b.charAt(0);
        // debug(a,b);
        if(a.equals(b))
            out.println("YES");
        else
            out.println("NO");
    }

    ///////////////////////////////////////////////////////////

    final long mod=(long)(1e9+7);
    final int inf=(int)(1e9+1);
    final int maxn=(int)(1e6);
    final long lim=(long)(1e18);

    public void run(){
        try{
            br=new BufferedReader(new InputStreamReader(System.in));
            st=null;
            out=new PrintWriter(System.out);

            solve();

            // int t=nextInt();
            // for(int i=1;i<=t;i++){
            //     // out.print("Case #"+i+": ");
            //     solve();
            // }

            br.close();
            out.close();
        }catch(Exception e){
            e.printStackTrace();
            System.exit(1);
        }
    }
    public static void main(String args[])throws IOException{
        new Main().run();
    }
    int max(int ... a){
        int ret=a[0];
        for(int i=1;i<a.length;i++)
        ret=Math.max(ret,a[i]);
        return ret;
    }
    int min(int ... a){
        int ret=a[0];
        for(int i=1;i<a.length;i++)
        ret=Math.min(ret,a[i]);
        return ret;
    }
    void debug(Object ... a){
        System.out.print("> ");
        for(int i=0;i<a.length;i++)
        System.out.print(a[i]+" ");
        System.out.println();
    }
    void debug(int a[]){debuga(Arrays.stream(a).boxed().toArray());}
    void debug(long a[]){debuga(Arrays.stream(a).boxed().toArray());}
    void debuga(Object a[]){
        System.out.print("> ");
        for(int i=0;i<a.length;i++)
        System.out.print(a[i]+" ");
        System.out.println();
    }
    BufferedReader br;
    StringTokenizer st;
    PrintWriter out;
    String nextToken()throws IOException{
        while(st==null || !st.hasMoreTokens())
        st=new StringTokenizer(br.readLine());
        return st.nextToken();
    }
    String nextLine()throws IOException{
        return br.readLine();
    }
    int nextInt()throws IOException{
        return Integer.parseInt(nextToken());
    }
    long nextLong()throws IOException{
        return Long.parseLong(nextToken());
    }
    double nextDouble()throws IOException{
        return Double.parseDouble(nextToken());
    }
}

import java.io.*;
import java.util.*;
public class Main implements Runnable{

    private void solve()throws IOException{
        String a="";
        String b="";
        String s[]=new String[4];
        for(int i=0;i<4;i++)
            s[i]=nextLine();
        if(s[0].charAt(0)!='X')
            a+=s[0].charAt(0);
        if(s[0].charAt(1)!='X')
            a+=s[0].charAt(1);
        if(s[1].charAt(1)!='X')
            a+=s[1].charAt(1);
        if(s[1].charAt(0)!='X')
            a+=s[1].charAt(0);

        if(s[2].charAt(0)!='X')
            b+=s[2].charAt(0);
        if(s[2].charAt(1)!='X')
            b+=s[2].charAt(1);
        if(s[3].charAt(1)!='X')
            b+=s[3].charAt(1);
        if(s[3].charAt(0)!='X')
            b+=s[3].charAt(0);

        while(a.charAt(0)!='A')
            b=b.substring(1,b.length())+b.charAt(0);
        while(a.charAt(0)!='A')
            a=a.substring(1,a.length())+a.charAt(0);

        if(a.equals(b))
            out.println("YES");
        else
            out.println("NO");
    }

    ///////////////////////////////////////////////////////////

    final long mod=(long)(1e9+7);
    final int inf=(int)(1e9+1);
    final int maxn=(int)(1e6);
    final long lim=(long)(1e18);

    public void run(){
        try{
            br=new BufferedReader(new InputStreamReader(System.in));
            st=null;
            out=new PrintWriter(System.out);

            solve();

            // int t=nextInt();
            // for(int i=1;i<=t;i++){
            //     // out.print("Case #"+i+": ");
            //     solve();
            // }

            br.close();
            out.close();
        }catch(Exception e){
            e.printStackTrace();
            System.exit(1);
        }
    }
    public static void main(String args[])throws IOException{
        new Main().run();
    }
    int max(int ... a){
        int ret=a[0];
        for(int i=1;i<a.length;i++)
        ret=Math.max(ret,a[i]);
        return ret;
    }
    int min(int ... a){
        int ret=a[0];
        for(int i=1;i<a.length;i++)
        ret=Math.min(ret,a[i]);
        return ret;
    }
    void debug(Object ... a){
        System.out.print("> ");
        for(int i=0;i<a.length;i++)
        System.out.print(a[i]+" ");
        System.out.println();
    }
    void debug(int a[]){debuga(Arrays.stream(a).boxed().toArray());}
    void debug(long a[]){debuga(Arrays.stream(a).boxed().toArray());}
    void debuga(Object a[]){
        System.out.print("> ");
        for(int i=0;i<a.length;i++)
        System.out.print(a[i]+" ");
        System.out.println();
    }
    BufferedReader br;
    StringTokenizer st;
    PrintWriter out;
    String nextToken()throws IOException{
        while(st==null || !st.hasMoreTokens())
        st=new StringTokenizer(br.readLine());
        return st.nextToken();
    }
    String nextLine()throws IOException{
        return br.readLine();
    }
    int nextInt()throws IOException{
        return Integer.parseInt(nextToken());
    }
    long nextLong()throws IOException{
        return Long.parseLong(nextToken());
    }
    double nextDouble()throws IOException{
        return Double.parseDouble(nextToken());
    }
}

import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;

public class SlidingPuzzles {

	public static void main(String[] args) throws Exception {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw = new PrintWriter(new BufferedOutputStream(System.out));

		ArrayList<String> slider1 = clockwiseArrangement(br);
		ArrayList<String> slider2 = clockwiseArrangement(br);

		slider1.remove("X");
		slider2.remove("X");

		//System.out.println(Arrays.toString(slider1.toArray()));
		//System.out.println(Arrays.toString(slider2.toArray()));

		slider2 = rotate(slider2, (slider2.indexOf("A") - slider1.indexOf("A") + 4) % 4);

		//System.out.println(Arrays.toString(slider2.toArray()));

		if(Arrays.equals(slider1.toArray(), slider2.toArray())) {
			pw.write("YES");
		} else {
			pw.write("NO");
		}

		//System.out.println(Arrays.toString(slider1.toArray()));
		//System.out.println(Arrays.toString(slider2.toArray()));

		br.close();
		pw.close();
	}

	public static ArrayList<String> clockwiseArrangement(BufferedReader br) throws Exception {
		ArrayList<String> circle = new ArrayList<>();
		String line;

		line = br.readLine();
		circle.add(line.split("")[0]);
		circle.add(line.split("")[1]);
		line = br.readLine();
		circle.add(line.split("")[1]);
		circle.add(line.split("")[0]);

		return circle;
	}

	public static ArrayList<String> rotate(ArrayList<String> circle, int shift) {
		for(int i = 0; i < shift; i++) {
			circle.add(0, circle.get(circle.size() - 1));
			circle.remove(circle.size()-1);
		}

		return circle;
	}

}

import java.util.*;
import java.io.*;

public class A {
    FastScanner in;
    PrintWriter out;

    int[][] sh = new int[][] {
            {1, 2},
            {0, 3},
            {0, 3},
            {1, 2}
    };

    public void solve() throws IOException {
        String s = in.next() + in.next();
        String t = in.next() + in.next();

        String[] q = new String[10000];
        int head = 0;
        int tail = 1;
        q[head] = s;
        Set<String> was = new HashSet<>();
        was.add(s);
        while (head < tail) {
            char[] cur = q[head++].toCharArray();
            int emp = q[head - 1].indexOf("X");
            for (int x : sh[emp]) {
                char tmp = cur[x];
                cur[x] = cur[emp];
                cur[emp] = tmp;

                String n = new String(cur);
                if (n.equals(t)) {
                    out.println("YES");
                    return;
                }
                if (was.contains(n)) continue;
                was.add(n);
                q[tail++] = n;
                tmp = cur[x];
                cur[x] = cur[emp];
                cur[emp] = tmp;
            }
        }
        out.println("NO");

    }

    public void run() {
        try {
            in = new FastScanner(System.in);
            out = new PrintWriter(System.out);
            Locale.setDefault(Locale.US);

            solve();

            out.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        FastScanner(InputStream f) {
            br = new BufferedReader(new InputStreamReader(f));
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }
    }

    public static void main(String[] arg) {
        new A().run();
    }
}

import java.util.Scanner;

public class AmityAssesment {

	public static void main(String[] args) {
		// TODO Auto-generated method stub

		Scanner input = new Scanner(System.in);
		String a = input.next();
	   a+=reverse(input.next());
	   String b = input.next();
	   b+=reverse(input.next());
	   if(a==b){
		   System.out.println("YES");
	     return;
	   }
	     String p=a;
	   a = next(a);
	  //System.out.println(b+" "+a);
	  while(!p.equals(a)){
		 // System.out.println(a+" "+b);
		  if(a.equals(b)){
			  System.out.println("YES");
		     return;
		  }
		  a = next(a);
	  }
	  System.out.println("NO");
	}

	private static String reverse(String s){
		String z = "";
		for(int i=s.length()-1; i>=0;i--)z+=s.charAt(i);
		return z;
	}

	private static String next(String s){
		int i = s.indexOf("X");
		String z = "";
		if(i!=s.length()-1){
			z+=s.substring(0,i);
		z+=reverse(s.substring(i,i+2));
		z+=s.substring(i+2);
			return z;
		}
		else{
			z+=s.charAt(s.length()-1)+s.substring(1,s.length()-1)+s.charAt(0);
			return z;
		}
	}

}

import java.util.*;
import java.io.*;

public class A {

	static BufferedReader br;
	static PrintWriter out;
	static StringTokenizer st;

	public static void main (String[] args) throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(new OutputStreamWriter(System.out));
		//br = new BufferedReader(new FileReader("in.txt"));
		//out = new PrintWriter(new FileWriter("out.txt"));

		char[][] g1 = new char[2][2];
		char[][] g2 = new char[2][2];

		for (int i = 0; i < 2; i++)
			g1[i] = readLine().toCharArray();

		for (int i = 0; i < 2; i++)
			g2[i] = readLine().toCharArray();

		String s1 = get(g1);
		String s2 = get(g2);
		if (s1.equals(s2)) {
			out.println("YES");
		} else {
			out.println("NO");
		}

		out.close();
	}

	static String get (char[][] g1) {
		String s1 = "";
		if (g1[0][0] == 'X')
			s1 += ""+g1[1][0] + g1[0][1] + g1[1][1];
		else if (g1[0][1] == 'X')
			s1 += ""+g1[0][0] + g1[1][1] + g1[1][0];
		else if (g1[1][1] == 'X')
			s1 += ""+g1[0][0] + g1[0][1] + g1[1][0];
		else if (g1[1][0] == 'X')
			s1 += ""+g1[0][0] + g1[0][1] + g1[1][1];
		return s1;
	}

	static String next () throws IOException {
		while (st == null || !st.hasMoreTokens())
			st = new StringTokenizer(br.readLine().trim());
		return st.nextToken();
	}

	static long readLong () throws IOException {
		return Long.parseLong(next());
	}

	static int readInt () throws IOException {
		return Integer.parseInt(next());
	}

	static double readDouble () throws IOException {
		return Double.parseDouble(next());
	}

	static char readCharacter () throws IOException {
		return next().charAt(0);
	}

	static String readLine () throws IOException {
		return br.readLine().trim();
	}
}

import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class CF {

    public static void main(String[] args) {
        InputReader inputReader = new InputReader(System.in);
        PrintWriter printWriter = new PrintWriter(System.out, true);

        String[] grids = new String[4];
        for (int i = 0; i < 4; i++) {
            grids[i] = inputReader.readLine();
        }

        StringBuilder firstGrid = new StringBuilder();
        firstGrid.append(grids[0]).append(grids[1].charAt(1)).append(grids[1].charAt(0));
        firstGrid.deleteCharAt(firstGrid.indexOf("X"));

        StringBuilder secondGrid = new StringBuilder();
        secondGrid.append(grids[2]).append(grids[3].charAt(1)).append(grids[3].charAt(0));
        secondGrid.deleteCharAt(secondGrid.indexOf("X"));

        String sub = secondGrid.substring(0, secondGrid.indexOf("A"));
        secondGrid.delete(0, secondGrid.indexOf("A")).append(sub);

        if (firstGrid.toString().equals(secondGrid.toString())) {
            printWriter.print("YES");
        } else {
            printWriter.print("NO");
        }

        printWriter.close();
    }

    private static class InputReader {
        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        public InputReader(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        public int[] nextIntArray(int size) {
            int[] array = new int[size];
            for (int i = 0; i < size; ++i) {
                array[i] = nextInt();
            }
            return array;
        }

        public long[] nextLongArray(int size) {
            long[] array = new long[size];
            for (int i = 0; i < size; ++i) {
                array[i] = nextLong();
            }
            return array;
        }

        public double[] nextDoubleArray(int size) {
            double[] array = new double[size];
            for (int i = 0; i < size; ++i) {
                array[i] = nextDouble();
            }
            return array;
        }

        public String[] nextStringArray(int size) {
            String[] array = new String[size];
            for (int i = 0; i < size; ++i) {
                array[i] = next();
            }
            return array;
        }

        public boolean[][] nextBooleanTable(int rows, int columns, char trueCharacter) {
            boolean[][] table = new boolean[rows][columns];
            for (int i = 0; i < rows; ++i) {
                String row = next();
                assert row.length() == columns;
                for (int j = 0; j < columns; ++j) {
                    table[i][j] = (row.charAt(j) == trueCharacter);
                }
            }
            return table;
        }

        public char[][] nextCharTable(int rows, int columns) {
            char[][] table = new char[rows][];
            for (int i = 0; i < rows; ++i) {
                table[i] = next().toCharArray();
                assert table[i].length == columns;
            }
            return table;
        }

        public int[][] nextIntTable(int rows, int columns) {
            int[][] table = new int[rows][columns];
            for (int i = 0; i < rows; i++) {
                for (int j = 0; j < columns; j++) {
                    table[i][j] = nextInt();
                }
            }
            return table;
        }

        public long[][] nextLongTable(int rows, int columns) {
            long[][] table = new long[rows][columns];
            for (int i = 0; i < rows; i++) {
                for (int j = 0; j < columns; j++) {
                    table[i][j] = nextLong();
                }
            }
            return table;
        }

        public double[][] nextDoubleTable(int rows, int columns) {
            double[][] table = new double[rows][columns];
            for (int i = 0; i < rows; i++) {
                for (int j = 0; j < columns; j++) {
                    table[i][j] = nextDouble();
                }
            }
            return table;
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public BigInteger nextBigInteger() {
            return new BigInteger(next());
        }

        public boolean hasNext() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                String line = readLine();
                if (line == null) {
                    return false;
                }
                tokenizer = new StringTokenizer(line);
            }
            return true;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                tokenizer = new StringTokenizer(readLine());
            }
            return tokenizer.nextToken();
        }

        public String readLine() {
            String line;
            try {
                line = reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            return line;
        }
    }
}

import java.util.*;

public class Solution{

	public static void main(String[] args)
	{
		Scanner in=new Scanner(System.in);
		char[][] bes=new char[2][2];
		char[][] esl=new char[2][2];

		for(int i=0;i<2;i++)
		{
			String s=in.next();
			bes[i][0]=s.charAt(0);
			bes[i][1]=s.charAt(1);
		}

		for(int i=0;i<2;i++)
		{
			String s=in.next();

			esl[i][0]=s.charAt(0);
			esl[i][1]=s.charAt(1);
		}

		int row=0,col=0;
		boolean cbc=false,cba=false;
		for(int i=0;i<2;i++)
			for(int j=0;j<2;j++)
			if(bes[i][j]=='A')
				{
					row=i;
					col=j;
				}

		if(row==0&&col==0)
		{
			if(bes[1][0]=='B'||bes[0][1]=='C')
				cbc=true;
			else
				cba=true;
		}
		else if(row==1&&col==0)
		{
			if(bes[0][0]=='C'||bes[1][1]=='B')
				cbc=true;
			else
				cba=true;
		}

		else if(row==0&&col==1)
		{
			if(bes[0][0]=='B'||bes[1][1]=='C')
				cbc=true;
			else
				cba=true;
		}

		else if(row==1&&col==1)
		{
			if(bes[0][1]=='B'||bes[1][0]=='C')
				cbc=true;
			else
				cba=true;
		}

		boolean cec=false,cea=false;
		for(int i=0;i<2;i++)
			for(int j=0;j<2;j++)
			if(bes[i][j]=='A')
				{
					row=i;
					col=j;
				}

		if(row==0&&col==0)
		{
			if(esl[1][0]=='B'||esl[0][1]=='C')
				cec=true;
			else
				cea=true;
		}
		else if(row==1&&col==0)
		{
			if(esl[0][0]=='C'||esl[1][1]=='B')
				cec=true;
			else
				cea=true;
		}

		else if(row==0&&col==1)
		{
			if(esl[0][0]=='B'||esl[1][1]=='C')
				cec=true;
			else
				cea=true;
		}

		else if(row==1&&col==1)
		{
			if(esl[0][1]=='B'||esl[1][0]=='C')
				cec=true;
			else
				cea=true;
		}

		if(cec!=cbc)
		System.out.println("NO");
		else
		System.out.println("YES");

	}
}

import java.util.*;

public class Solution{

	public static void main(String[] args)
	{
		Scanner in=new Scanner(System.in);
		char[][] bes=new char[2][2];
		char[][] esl=new char[2][2];

		for(int i=0;i<2;i++)
		{
			String s=in.next();
			bes[i][0]=s.charAt(0);
			bes[i][1]=s.charAt(1);
		}

		for(int i=0;i<2;i++)
		{
			String s=in.next();

			esl[i][0]=s.charAt(0);
			esl[i][1]=s.charAt(1);
		}

		int count=0;
		for(int i=0;i<2;i++)
			for(int j=0;j<2;j++)
			if((bes[i][j]==esl[i][j])&&bes[i][j]!='X')
				count++;

		if((3-count)==2)
		System.out.println("NO");
		else
		System.out.println("YES");

	}
}