import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] s = new String[3];
		for (int i = 0; i < 3; i++) {
			s[i] = sc.next();
		}
		int i = 0;

		while (s[i].length()!=0) {
			int n = s[i].charAt(0) - 'a';
			s[i] = s[i].substring(1);
			i=n;
		}
		System.out.println((char)('A'+i));

	}

} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] s = new String[3];
		for (int i = 0; i < 3; i++) {
			s[i] = sc.next();
		}
		int i = 0;

		while (s[i].length()!=0) {
			int n = s[i].charAt(0) - 'a';
			s[i] = s[i].substring(1);
			i=n;
		}
		System.out.println((char)('A'+i));

	}

} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] s = new String[3];
		for (int i = 0; i < 3; i++) {
			s[i] = sc.next();
		}
		int i = 0;

		while (s[i].length()!=0) {
			int n = s[i].charAt(0) - 'a';
			s[i] = s[i].substring(1);
			i=n;
		}
		System.out.println((char)('A'+i));

	} main {
		Scanner sc = new Scanner(System.in);
		String[] s = new String[3];
		for (int i = 0; i < 3; i++) {
			s[i] = sc.next();
		}
		int i = 0;

		while (s[i].length()!=0) {
			int n = s[i].charAt(0) - 'a';
			s[i] = s[i].substring(1);
			i=n;
		}
		System.out.println((char)('A'+i));

	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String[] s = new String[3]; s new String[3] 3 for (int i = 0; i < 3; i++) {
			s[i] = sc.next();
		} int i = 0; int i = 0; i 0 i < 3 i 3 i++ i++ i {
			s[i] = sc.next();
		} {
			s[i] = sc.next();
		} s[i] = sc.next() s[i] s i sc.next() sc.next sc int i = 0; i 0 while (s[i].length()!=0) {
			int n = s[i].charAt(0) - 'a';
			s[i] = s[i].substring(1);
			i=n;
		} s[i].length()!=0 s[i].length() s[i].length s[i] s i 0 {
			int n = s[i].charAt(0) - 'a';
			s[i] = s[i].substring(1);
			i=n;
		} int n = s[i].charAt(0) - 'a'; n s[i].charAt(0) - 'a' s[i].charAt(0) s[i].charAt s[i] s i 0 'a' s[i] = s[i].substring(1) s[i] s i s[i].substring(1) s[i].substring s[i] s i 1 i=n i n System.out.println((char)('A'+i)) System.out.println System.out System System.out (char)('A'+i) 'A' i String[] args args public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] s = new String[3];
		for (int i = 0; i < 3; i++) {
			s[i] = sc.next();
		}
		int i = 0;

		while (s[i].length()!=0) {
			int n = s[i].charAt(0) - 'a';
			s[i] = s[i].substring(1);
			i=n;
		}
		System.out.println((char)('A'+i));

	}

} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] s = new String[3];
		for (int i = 0; i < 3; i++) {
			s[i] = sc.next();
		}
		int i = 0;

		while (s[i].length()!=0) {
			int n = s[i].charAt(0) - 'a';
			s[i] = s[i].substring(1);
			i=n;
		}
		System.out.println((char)('A'+i));

	}

} Main
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] s = new String[3];
		for (int i = 0; i < 3; i++) {
			s[i] = sc.next();
		}
		int i = 0;

		while (s[i].length()!=0) {
			int n = s[i].charAt(0) - 'a';
			s[i] = s[i].substring(1);
			i=n;
		}
		System.out.println((char)('A'+i));

	}

}