import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

class Main {
	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		String a = scanner.next();
		String b = scanner.next();
		String c = scanner.next();
		Map<String, String> map = new HashMap<>();

		map.put("a", a);
		map.put("b", b);
		map.put("c", c);

		String key = "a";
		while (true) {
			String target = map.get(key).substring(0, 1);
			if (map.get(key).equals("end")) {
				System.out.println(key.toUpperCase());
				return;
			}

			if (map.get(key).substring(1, map.get(key).length()).length() >= 1) {
				map.put(key, map.get(key).substring(1, map.get(key).length()));
			} else {
				map.put(key, "end");
			}
			key = target;
		}

	}

} import java.util.HashMap; HashMap java.util import java.util.Map; Map java.util import java.util.Scanner; Scanner java.util class Main {
	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		String a = scanner.next();
		String b = scanner.next();
		String c = scanner.next();
		Map<String, String> map = new HashMap<>();

		map.put("a", a);
		map.put("b", b);
		map.put("c", c);

		String key = "a";
		while (true) {
			String target = map.get(key).substring(0, 1);
			if (map.get(key).equals("end")) {
				System.out.println(key.toUpperCase());
				return;
			}

			if (map.get(key).substring(1, map.get(key).length()).length() >= 1) {
				map.put(key, map.get(key).substring(1, map.get(key).length()));
			} else {
				map.put(key, "end");
			}
			key = target;
		}

	}

} Main @SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		String a = scanner.next();
		String b = scanner.next();
		String c = scanner.next();
		Map<String, String> map = new HashMap<>();

		map.put("a", a);
		map.put("b", b);
		map.put("c", c);

		String key = "a";
		while (true) {
			String target = map.get(key).substring(0, 1);
			if (map.get(key).equals("end")) {
				System.out.println(key.toUpperCase());
				return;
			}

			if (map.get(key).substring(1, map.get(key).length()).length() >= 1) {
				map.put(key, map.get(key).substring(1, map.get(key).length()));
			} else {
				map.put(key, "end");
			}
			key = target;
		}

	} main {
		Scanner scanner = new Scanner(System.in);
		String a = scanner.next();
		String b = scanner.next();
		String c = scanner.next();
		Map<String, String> map = new HashMap<>();

		map.put("a", a);
		map.put("b", b);
		map.put("c", c);

		String key = "a";
		while (true) {
			String target = map.get(key).substring(0, 1);
			if (map.get(key).equals("end")) {
				System.out.println(key.toUpperCase());
				return;
			}

			if (map.get(key).substring(1, map.get(key).length()).length() >= 1) {
				map.put(key, map.get(key).substring(1, map.get(key).length()));
			} else {
				map.put(key, "end");
			}
			key = target;
		}

	} Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) String a = scanner.next(); a scanner.next() scanner.next scanner String b = scanner.next(); b scanner.next() scanner.next scanner String c = scanner.next(); c scanner.next() scanner.next scanner Map<String, String> map = new HashMap<>(); map new HashMap<>() map.put("a", a) map.put map "a" a map.put("b", b) map.put map "b" b map.put("c", c) map.put map "c" c String key = "a"; key "a" while (true) {
			String target = map.get(key).substring(0, 1);
			if (map.get(key).equals("end")) {
				System.out.println(key.toUpperCase());
				return;
			}

			if (map.get(key).substring(1, map.get(key).length()).length() >= 1) {
				map.put(key, map.get(key).substring(1, map.get(key).length()));
			} else {
				map.put(key, "end");
			}
			key = target;
		} true {
			String target = map.get(key).substring(0, 1);
			if (map.get(key).equals("end")) {
				System.out.println(key.toUpperCase());
				return;
			}

			if (map.get(key).substring(1, map.get(key).length()).length() >= 1) {
				map.put(key, map.get(key).substring(1, map.get(key).length()));
			} else {
				map.put(key, "end");
			}
			key = target;
		} String target = map.get(key).substring(0, 1); target map.get(key).substring(0, 1) map.get(key).substring map.get(key) map.get map key 0 1 if (map.get(key).equals("end")) {
				System.out.println(key.toUpperCase());
				return;
			} map.get(key).equals("end") map.get(key).equals map.get(key) map.get map key "end" {
				System.out.println(key.toUpperCase());
				return;
			} System.out.println(key.toUpperCase()) System.out.println System.out System System.out key.toUpperCase() key.toUpperCase key return; if (map.get(key).substring(1, map.get(key).length()).length() >= 1) {
				map.put(key, map.get(key).substring(1, map.get(key).length()));
			} else {
				map.put(key, "end");
			} map.get(key).substring(1, map.get(key).length()).length() >= 1 map.get(key).substring(1, map.get(key).length()).length() map.get(key).substring(1, map.get(key).length()).length map.get(key).substring(1, map.get(key).length()) map.get(key).substring map.get(key) map.get map key 1 map.get(key).length() map.get(key).length map.get(key) map.get map key 1 {
				map.put(key, map.get(key).substring(1, map.get(key).length()));
			} map.put(key, map.get(key).substring(1, map.get(key).length())) map.put map key map.get(key).substring(1, map.get(key).length()) map.get(key).substring map.get(key) map.get map key 1 map.get(key).length() map.get(key).length map.get(key) map.get map key {
				map.put(key, "end");
			} map.put(key, "end") map.put map key "end" key = target key target String args[] args
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

class Main {
	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		String a = scanner.next();
		String b = scanner.next();
		String c = scanner.next();
		Map<String, String> map = new HashMap<>();

		map.put("a", a);
		map.put("b", b);
		map.put("c", c);

		String key = "a";
		while (true) {
			String target = map.get(key).substring(0, 1);
			if (map.get(key).equals("end")) {
				System.out.println(key.toUpperCase());
				return;
			}

			if (map.get(key).substring(1, map.get(key).length()).length() >= 1) {
				map.put(key, map.get(key).substring(1, map.get(key).length()));
			} else {
				map.put(key, "end");
			}
			key = target;
		}

	}

}