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 p = 0;
		while(s[p].length() != 0){
			int np = s[p].charAt(0)-'a';
			s[p] = s[p].substring(1,s[p].length());
			// else s[p] = "";
			p = np;
		}
		System.out.println((char)('A'+p));
	}

} 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 p = 0;
		while(s[p].length() != 0){
			int np = s[p].charAt(0)-'a';
			s[p] = s[p].substring(1,s[p].length());
			// else s[p] = "";
			p = np;
		}
		System.out.println((char)('A'+p));
	}

} 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 p = 0;
		while(s[p].length() != 0){
			int np = s[p].charAt(0)-'a';
			s[p] = s[p].substring(1,s[p].length());
			// else s[p] = "";
			p = np;
		}
		System.out.println((char)('A'+p));
	} main {
		Scanner sc = new Scanner(System.in);
		String[] s = new String[3];
		for (int i = 0;i < 3 ; i++ ) {
			s[i] = sc.next();
		}
		int p = 0;
		while(s[p].length() != 0){
			int np = s[p].charAt(0)-'a';
			s[p] = s[p].substring(1,s[p].length());
			// else s[p] = "";
			p = np;
		}
		System.out.println((char)('A'+p));
	} 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 p = 0; p 0 while(s[p].length() != 0){
			int np = s[p].charAt(0)-'a';
			s[p] = s[p].substring(1,s[p].length());
			// else s[p] = "";
			p = np;
		} s[p].length() != 0 s[p].length() s[p].length s[p] s p 0 {
			int np = s[p].charAt(0)-'a';
			s[p] = s[p].substring(1,s[p].length());
			// else s[p] = "";
			p = np;
		} int np = s[p].charAt(0)-'a'; np s[p].charAt(0)-'a' s[p].charAt(0) s[p].charAt s[p] s p 0 'a' s[p] = s[p].substring(1,s[p].length()) s[p] s p s[p].substring(1,s[p].length()) s[p].substring s[p] s p 1 s[p].length() s[p].length s[p] s p p = np p np System.out.println((char)('A'+p)) System.out.println System.out System System.out (char)('A'+p) 'A' p 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 p = 0;
		while(s[p].length() != 0){
			int np = s[p].charAt(0)-'a';
			s[p] = s[p].substring(1,s[p].length());
			// else s[p] = "";
			p = np;
		}
		System.out.println((char)('A'+p));
	}

} 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 p = 0;
		while(s[p].length() != 0){
			int np = s[p].charAt(0)-'a';
			s[p] = s[p].substring(1,s[p].length());
			// else s[p] = "";
			p = np;
		}
		System.out.println((char)('A'+p));
	}

} 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 p = 0;
		while(s[p].length() != 0){
			int np = s[p].charAt(0)-'a';
			s[p] = s[p].substring(1,s[p].length());
			// else s[p] = "";
			p = np;
		}
		System.out.println((char)('A'+p));
	}

}