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

public class cube_ab implements Runnable {

	int[][] c = {
			{0, 0, 0},
			{0, 2, 0},
			{2, 2, 0},
			{2, 0, 0},
			{0, 0, 2},
			{0, 2, 2},
			{2, 2, 2},
			{2, 0, 2}
			};
	
	String[] cs = new String[]{"A", "B", "C", "D", "A1", "B1", "C1", "D1"};
	
	
	private void solve() throws IOException {
		int[] u = getC();
		int[] v = getC();
		myAssert(u[0] != v[0] || u[1] != v[1]);
		for (int i = -1; i <= 1; ++i) {
			loop:
			for (int j = -1; j <= 1; ++j) {
				for (int k = 0; k < 3; ++k) {
					if (c[u[0]][k] * (1 + i) + (1 - i) * c[u[1]][k] != c[v[0]][k] * (1 + j) + (1 - j) * c[v[1]][k]) {
						continue loop;
					}
				}
				out.println("Yes");
				return;
			}
		}
		out.println("No");
	}

	private int[] getC() {
		String s = in.next();
		for (int i = 0; i < cs.length; ++i) {
			for (int j = 0; j < cs.length; ++j) {
				if (i == j) continue;
				if ((cs[i] + cs[j]).equals(s)) {
					return new int[]{Math.min(i, j), Math.max(i, j)}; 
				}
			}
		}
		throw new Error("Don't understand");
	}

	void myAssert(boolean e) {
		if (!e) {
			throw new Error("Assertion failed");
		}
	}
	
	final String FILE_NAME = "cube";

	SimpleScanner in;
	PrintWriter out;

	@Override
	public void run() {
		try {
			in = new SimpleScanner(new FileReader(FILE_NAME + ".in"));
			out = new PrintWriter(FILE_NAME + ".out");
			solve();
			out.close();
		} catch (Throwable e) {
			e.printStackTrace();
			System.exit(-1);
		}
	}

	public static void main(String[] args) {
		new Thread(new cube_ab()).start();
	}

	class SimpleScanner extends BufferedReader {

		private StringTokenizer st;
		private boolean eof;

		public SimpleScanner(Reader a) {
			super(a);
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(readLine());
				} catch (Exception e) {
					eof = true;
					return "";
				}
			}
			return st.nextToken();
		}

		boolean seekEof() {
			String s = next();
			if ("".equals(s) && eof)
				return true;
			st = new StringTokenizer(s + " " + st.toString());
			return false;
		}

		private String cnv(String s) {
			if (s.length() == 0)
				return "0";
			return s;
		}

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

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

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