import java.util.Scanner;

class Main {

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

		String a = sc.next();
		String b = sc.next();
		String c = sc.next();
		String n = a;

		while (n.length() > 0) {
			if (n.equals(a)) {
				if (a.substring(0, 1).equals("a")) {
					a = a.substring(1);
					n = a;
				} else if (a.substring(0, 1).equals("b")) {
					a = a.substring(1);
					n = b;
				} else if (a.substring(0, 1).equals("c")) {
					a = a.substring(1);
					n = c;
				}
			} else if (n.equals(b)) {
				if (b.substring(0, 1).equals("a")) {
					b = b.substring(1);
					n = a;
				} else if (b.substring(0, 1).equals("b")) {
					b = b.substring(1);
					n = b;
				} else if (b.substring(0, 1).equals("c")) {
					b = b.substring(1);
					n = c;
				}
			} else if (n.equals(c)) {
				if (c.substring(0, 1).equals("a")) {
					c = c.substring(1);
					n = a;
				} else if (c.substring(0, 1).equals("b")) {
					c = c.substring(1);
					n = b;
				} else if (c.substring(0, 1).equals("c")) {
					c = c.substring(1);
					n = c;
				}
			}
		}
		if (n == a) {
			System.out.println("A");
		} else if (n == b) {
			System.out.println("B");
		} else if (n == c) {
			System.out.println("C");
		}
	}
} import java.util.Scanner; Scanner java.util class Main {

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

		String a = sc.next();
		String b = sc.next();
		String c = sc.next();
		String n = a;

		while (n.length() > 0) {
			if (n.equals(a)) {
				if (a.substring(0, 1).equals("a")) {
					a = a.substring(1);
					n = a;
				} else if (a.substring(0, 1).equals("b")) {
					a = a.substring(1);
					n = b;
				} else if (a.substring(0, 1).equals("c")) {
					a = a.substring(1);
					n = c;
				}
			} else if (n.equals(b)) {
				if (b.substring(0, 1).equals("a")) {
					b = b.substring(1);
					n = a;
				} else if (b.substring(0, 1).equals("b")) {
					b = b.substring(1);
					n = b;
				} else if (b.substring(0, 1).equals("c")) {
					b = b.substring(1);
					n = c;
				}
			} else if (n.equals(c)) {
				if (c.substring(0, 1).equals("a")) {
					c = c.substring(1);
					n = a;
				} else if (c.substring(0, 1).equals("b")) {
					c = c.substring(1);
					n = b;
				} else if (c.substring(0, 1).equals("c")) {
					c = c.substring(1);
					n = c;
				}
			}
		}
		if (n == a) {
			System.out.println("A");
		} else if (n == b) {
			System.out.println("B");
		} else if (n == c) {
			System.out.println("C");
		}
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String a = sc.next();
		String b = sc.next();
		String c = sc.next();
		String n = a;

		while (n.length() > 0) {
			if (n.equals(a)) {
				if (a.substring(0, 1).equals("a")) {
					a = a.substring(1);
					n = a;
				} else if (a.substring(0, 1).equals("b")) {
					a = a.substring(1);
					n = b;
				} else if (a.substring(0, 1).equals("c")) {
					a = a.substring(1);
					n = c;
				}
			} else if (n.equals(b)) {
				if (b.substring(0, 1).equals("a")) {
					b = b.substring(1);
					n = a;
				} else if (b.substring(0, 1).equals("b")) {
					b = b.substring(1);
					n = b;
				} else if (b.substring(0, 1).equals("c")) {
					b = b.substring(1);
					n = c;
				}
			} else if (n.equals(c)) {
				if (c.substring(0, 1).equals("a")) {
					c = c.substring(1);
					n = a;
				} else if (c.substring(0, 1).equals("b")) {
					c = c.substring(1);
					n = b;
				} else if (c.substring(0, 1).equals("c")) {
					c = c.substring(1);
					n = c;
				}
			}
		}
		if (n == a) {
			System.out.println("A");
		} else if (n == b) {
			System.out.println("B");
		} else if (n == c) {
			System.out.println("C");
		}
	} main {
		Scanner sc = new Scanner(System.in);

		String a = sc.next();
		String b = sc.next();
		String c = sc.next();
		String n = a;

		while (n.length() > 0) {
			if (n.equals(a)) {
				if (a.substring(0, 1).equals("a")) {
					a = a.substring(1);
					n = a;
				} else if (a.substring(0, 1).equals("b")) {
					a = a.substring(1);
					n = b;
				} else if (a.substring(0, 1).equals("c")) {
					a = a.substring(1);
					n = c;
				}
			} else if (n.equals(b)) {
				if (b.substring(0, 1).equals("a")) {
					b = b.substring(1);
					n = a;
				} else if (b.substring(0, 1).equals("b")) {
					b = b.substring(1);
					n = b;
				} else if (b.substring(0, 1).equals("c")) {
					b = b.substring(1);
					n = c;
				}
			} else if (n.equals(c)) {
				if (c.substring(0, 1).equals("a")) {
					c = c.substring(1);
					n = a;
				} else if (c.substring(0, 1).equals("b")) {
					c = c.substring(1);
					n = b;
				} else if (c.substring(0, 1).equals("c")) {
					c = c.substring(1);
					n = c;
				}
			}
		}
		if (n == a) {
			System.out.println("A");
		} else if (n == b) {
			System.out.println("B");
		} else if (n == c) {
			System.out.println("C");
		}
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String a = sc.next(); a sc.next() sc.next sc String b = sc.next(); b sc.next() sc.next sc String c = sc.next(); c sc.next() sc.next sc String n = a; n a while (n.length() > 0) {
			if (n.equals(a)) {
				if (a.substring(0, 1).equals("a")) {
					a = a.substring(1);
					n = a;
				} else if (a.substring(0, 1).equals("b")) {
					a = a.substring(1);
					n = b;
				} else if (a.substring(0, 1).equals("c")) {
					a = a.substring(1);
					n = c;
				}
			} else if (n.equals(b)) {
				if (b.substring(0, 1).equals("a")) {
					b = b.substring(1);
					n = a;
				} else if (b.substring(0, 1).equals("b")) {
					b = b.substring(1);
					n = b;
				} else if (b.substring(0, 1).equals("c")) {
					b = b.substring(1);
					n = c;
				}
			} else if (n.equals(c)) {
				if (c.substring(0, 1).equals("a")) {
					c = c.substring(1);
					n = a;
				} else if (c.substring(0, 1).equals("b")) {
					c = c.substring(1);
					n = b;
				} else if (c.substring(0, 1).equals("c")) {
					c = c.substring(1);
					n = c;
				}
			}
		} n.length() > 0 n.length() n.length n 0 {
			if (n.equals(a)) {
				if (a.substring(0, 1).equals("a")) {
					a = a.substring(1);
					n = a;
				} else if (a.substring(0, 1).equals("b")) {
					a = a.substring(1);
					n = b;
				} else if (a.substring(0, 1).equals("c")) {
					a = a.substring(1);
					n = c;
				}
			} else if (n.equals(b)) {
				if (b.substring(0, 1).equals("a")) {
					b = b.substring(1);
					n = a;
				} else if (b.substring(0, 1).equals("b")) {
					b = b.substring(1);
					n = b;
				} else if (b.substring(0, 1).equals("c")) {
					b = b.substring(1);
					n = c;
				}
			} else if (n.equals(c)) {
				if (c.substring(0, 1).equals("a")) {
					c = c.substring(1);
					n = a;
				} else if (c.substring(0, 1).equals("b")) {
					c = c.substring(1);
					n = b;
				} else if (c.substring(0, 1).equals("c")) {
					c = c.substring(1);
					n = c;
				}
			}
		} if (n.equals(a)) {
				if (a.substring(0, 1).equals("a")) {
					a = a.substring(1);
					n = a;
				} else if (a.substring(0, 1).equals("b")) {
					a = a.substring(1);
					n = b;
				} else if (a.substring(0, 1).equals("c")) {
					a = a.substring(1);
					n = c;
				}
			} else if (n.equals(b)) {
				if (b.substring(0, 1).equals("a")) {
					b = b.substring(1);
					n = a;
				} else if (b.substring(0, 1).equals("b")) {
					b = b.substring(1);
					n = b;
				} else if (b.substring(0, 1).equals("c")) {
					b = b.substring(1);
					n = c;
				}
			} else if (n.equals(c)) {
				if (c.substring(0, 1).equals("a")) {
					c = c.substring(1);
					n = a;
				} else if (c.substring(0, 1).equals("b")) {
					c = c.substring(1);
					n = b;
				} else if (c.substring(0, 1).equals("c")) {
					c = c.substring(1);
					n = c;
				}
			} n.equals(a) n.equals n a {
				if (a.substring(0, 1).equals("a")) {
					a = a.substring(1);
					n = a;
				} else if (a.substring(0, 1).equals("b")) {
					a = a.substring(1);
					n = b;
				} else if (a.substring(0, 1).equals("c")) {
					a = a.substring(1);
					n = c;
				}
			} if (a.substring(0, 1).equals("a")) {
					a = a.substring(1);
					n = a;
				} else if (a.substring(0, 1).equals("b")) {
					a = a.substring(1);
					n = b;
				} else if (a.substring(0, 1).equals("c")) {
					a = a.substring(1);
					n = c;
				} a.substring(0, 1).equals("a") a.substring(0, 1).equals a.substring(0, 1) a.substring a 0 1 "a" {
					a = a.substring(1);
					n = a;
				} a = a.substring(1) a a.substring(1) a.substring a 1 n = a n a if (a.substring(0, 1).equals("b")) {
					a = a.substring(1);
					n = b;
				} else if (a.substring(0, 1).equals("c")) {
					a = a.substring(1);
					n = c;
				} a.substring(0, 1).equals("b") a.substring(0, 1).equals a.substring(0, 1) a.substring a 0 1 "b" {
					a = a.substring(1);
					n = b;
				} a = a.substring(1) a a.substring(1) a.substring a 1 n = b n b if (a.substring(0, 1).equals("c")) {
					a = a.substring(1);
					n = c;
				} a.substring(0, 1).equals("c") a.substring(0, 1).equals a.substring(0, 1) a.substring a 0 1 "c" {
					a = a.substring(1);
					n = c;
				} a = a.substring(1) a a.substring(1) a.substring a 1 n = c n c if (n.equals(b)) {
				if (b.substring(0, 1).equals("a")) {
					b = b.substring(1);
					n = a;
				} else if (b.substring(0, 1).equals("b")) {
					b = b.substring(1);
					n = b;
				} else if (b.substring(0, 1).equals("c")) {
					b = b.substring(1);
					n = c;
				}
			} else if (n.equals(c)) {
				if (c.substring(0, 1).equals("a")) {
					c = c.substring(1);
					n = a;
				} else if (c.substring(0, 1).equals("b")) {
					c = c.substring(1);
					n = b;
				} else if (c.substring(0, 1).equals("c")) {
					c = c.substring(1);
					n = c;
				}
			} n.equals(b) n.equals n b {
				if (b.substring(0, 1).equals("a")) {
					b = b.substring(1);
					n = a;
				} else if (b.substring(0, 1).equals("b")) {
					b = b.substring(1);
					n = b;
				} else if (b.substring(0, 1).equals("c")) {
					b = b.substring(1);
					n = c;
				}
			} if (b.substring(0, 1).equals("a")) {
					b = b.substring(1);
					n = a;
				} else if (b.substring(0, 1).equals("b")) {
					b = b.substring(1);
					n = b;
				} else if (b.substring(0, 1).equals("c")) {
					b = b.substring(1);
					n = c;
				} b.substring(0, 1).equals("a") b.substring(0, 1).equals b.substring(0, 1) b.substring b 0 1 "a" {
					b = b.substring(1);
					n = a;
				} b = b.substring(1) b b.substring(1) b.substring b 1 n = a n a if (b.substring(0, 1).equals("b")) {
					b = b.substring(1);
					n = b;
				} else if (b.substring(0, 1).equals("c")) {
					b = b.substring(1);
					n = c;
				} b.substring(0, 1).equals("b") b.substring(0, 1).equals b.substring(0, 1) b.substring b 0 1 "b" {
					b = b.substring(1);
					n = b;
				} b = b.substring(1) b b.substring(1) b.substring b 1 n = b n b if (b.substring(0, 1).equals("c")) {
					b = b.substring(1);
					n = c;
				} b.substring(0, 1).equals("c") b.substring(0, 1).equals b.substring(0, 1) b.substring b 0 1 "c" {
					b = b.substring(1);
					n = c;
				} b = b.substring(1) b b.substring(1) b.substring b 1 n = c n c if (n.equals(c)) {
				if (c.substring(0, 1).equals("a")) {
					c = c.substring(1);
					n = a;
				} else if (c.substring(0, 1).equals("b")) {
					c = c.substring(1);
					n = b;
				} else if (c.substring(0, 1).equals("c")) {
					c = c.substring(1);
					n = c;
				}
			} n.equals(c) n.equals n c {
				if (c.substring(0, 1).equals("a")) {
					c = c.substring(1);
					n = a;
				} else if (c.substring(0, 1).equals("b")) {
					c = c.substring(1);
					n = b;
				} else if (c.substring(0, 1).equals("c")) {
					c = c.substring(1);
					n = c;
				}
			} if (c.substring(0, 1).equals("a")) {
					c = c.substring(1);
					n = a;
				} else if (c.substring(0, 1).equals("b")) {
					c = c.substring(1);
					n = b;
				} else if (c.substring(0, 1).equals("c")) {
					c = c.substring(1);
					n = c;
				} c.substring(0, 1).equals("a") c.substring(0, 1).equals c.substring(0, 1) c.substring c 0 1 "a" {
					c = c.substring(1);
					n = a;
				} c = c.substring(1) c c.substring(1) c.substring c 1 n = a n a if (c.substring(0, 1).equals("b")) {
					c = c.substring(1);
					n = b;
				} else if (c.substring(0, 1).equals("c")) {
					c = c.substring(1);
					n = c;
				} c.substring(0, 1).equals("b") c.substring(0, 1).equals c.substring(0, 1) c.substring c 0 1 "b" {
					c = c.substring(1);
					n = b;
				} c = c.substring(1) c c.substring(1) c.substring c 1 n = b n b if (c.substring(0, 1).equals("c")) {
					c = c.substring(1);
					n = c;
				} c.substring(0, 1).equals("c") c.substring(0, 1).equals c.substring(0, 1) c.substring c 0 1 "c" {
					c = c.substring(1);
					n = c;
				} c = c.substring(1) c c.substring(1) c.substring c 1 n = c n c if (n == a) {
			System.out.println("A");
		} else if (n == b) {
			System.out.println("B");
		} else if (n == c) {
			System.out.println("C");
		} n == a n a {
			System.out.println("A");
		} System.out.println("A") System.out.println System.out System System.out "A" if (n == b) {
			System.out.println("B");
		} else if (n == c) {
			System.out.println("C");
		} n == b n b {
			System.out.println("B");
		} System.out.println("B") System.out.println System.out System System.out "B" if (n == c) {
			System.out.println("C");
		} n == c n c {
			System.out.println("C");
		} System.out.println("C") System.out.println System.out System System.out "C" String[] args args
import java.util.Scanner;

class Main {

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

		String a = sc.next();
		String b = sc.next();
		String c = sc.next();
		String n = a;

		while (n.length() > 0) {
			if (n.equals(a)) {
				if (a.substring(0, 1).equals("a")) {
					a = a.substring(1);
					n = a;
				} else if (a.substring(0, 1).equals("b")) {
					a = a.substring(1);
					n = b;
				} else if (a.substring(0, 1).equals("c")) {
					a = a.substring(1);
					n = c;
				}
			} else if (n.equals(b)) {
				if (b.substring(0, 1).equals("a")) {
					b = b.substring(1);
					n = a;
				} else if (b.substring(0, 1).equals("b")) {
					b = b.substring(1);
					n = b;
				} else if (b.substring(0, 1).equals("c")) {
					b = b.substring(1);
					n = c;
				}
			} else if (n.equals(c)) {
				if (c.substring(0, 1).equals("a")) {
					c = c.substring(1);
					n = a;
				} else if (c.substring(0, 1).equals("b")) {
					c = c.substring(1);
					n = b;
				} else if (c.substring(0, 1).equals("c")) {
					c = c.substring(1);
					n = c;
				}
			}
		}
		if (n == a) {
			System.out.println("A");
		} else if (n == b) {
			System.out.println("B");
		} else if (n == c) {
			System.out.println("C");
		}
	}
}
