import java.util.Scanner;

public 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[] S = new String[] {A,B,C};
		sc.close();
		int num = 0;
		while(S[num].length() != 0) {
			int cnt = S[num].charAt(0) - 'a';
			S[num] = S[num].substring(1);
			num = cnt;
		}
		System.out.println((char)('A' + num));
	}
} import java.util.Scanner; Scanner java.util public 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[] S = new String[] {A,B,C};
		sc.close();
		int num = 0;
		while(S[num].length() != 0) {
			int cnt = S[num].charAt(0) - 'a';
			S[num] = S[num].substring(1);
			num = cnt;
		}
		System.out.println((char)('A' + num));
	}
} 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[] S = new String[] {A,B,C};
		sc.close();
		int num = 0;
		while(S[num].length() != 0) {
			int cnt = S[num].charAt(0) - 'a';
			S[num] = S[num].substring(1);
			num = cnt;
		}
		System.out.println((char)('A' + num));
	} main {
		Scanner sc = new Scanner(System.in);
		String A = sc.next();
		String B = sc.next();
		String C = sc.next();
		String[] S = new String[] {A,B,C};
		sc.close();
		int num = 0;
		while(S[num].length() != 0) {
			int cnt = S[num].charAt(0) - 'a';
			S[num] = S[num].substring(1);
			num = cnt;
		}
		System.out.println((char)('A' + num));
	} 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[] S = new String[] {A,B,C}; S new String[] {A,B,C} sc.close() sc.close sc int num = 0; num 0 while(S[num].length() != 0) {
			int cnt = S[num].charAt(0) - 'a';
			S[num] = S[num].substring(1);
			num = cnt;
		} S[num].length() != 0 S[num].length() S[num].length S[num] S num 0 {
			int cnt = S[num].charAt(0) - 'a';
			S[num] = S[num].substring(1);
			num = cnt;
		} int cnt = S[num].charAt(0) - 'a'; cnt S[num].charAt(0) - 'a' S[num].charAt(0) S[num].charAt S[num] S num 0 'a' S[num] = S[num].substring(1) S[num] S num S[num].substring(1) S[num].substring S[num] S num 1 num = cnt num cnt System.out.println((char)('A' + num)) System.out.println System.out System System.out (char)('A' + num) 'A' num String[] args args public 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[] S = new String[] {A,B,C};
		sc.close();
		int num = 0;
		while(S[num].length() != 0) {
			int cnt = S[num].charAt(0) - 'a';
			S[num] = S[num].substring(1);
			num = cnt;
		}
		System.out.println((char)('A' + num));
	}
} public 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[] S = new String[] {A,B,C};
		sc.close();
		int num = 0;
		while(S[num].length() != 0) {
			int cnt = S[num].charAt(0) - 'a';
			S[num] = S[num].substring(1);
			num = cnt;
		}
		System.out.println((char)('A' + num));
	}
} Main
import java.util.Scanner;

public 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[] S = new String[] {A,B,C};
		sc.close();
		int num = 0;
		while(S[num].length() != 0) {
			int cnt = S[num].charAt(0) - 'a';
			S[num] = S[num].substring(1);
			num = cnt;
		}
		System.out.println((char)('A' + num));
	}
}