import java.util.*;
import java.io.PrintWriter;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		char[][] s = new char[3][];
		s[0] = sc.next().toCharArray();
		s[1] = sc.next().toCharArray();
		s[2] = sc.next().toCharArray();
		sc.close();
		int[] sp = new int[3]; 
		int abc = 0;
		int tmp = 0;
		while(sp[abc] != s[abc].length) {
			tmp = (int)(s[abc][sp[abc]] - 'a');
			sp[abc]++;
			abc=tmp;
		}
		out.println((char)('A'+abc));
	}
} import java.util.*; util.* java import java.io.PrintWriter; PrintWriter java.io import static java.lang.Integer.*; import static java.lang.Integer.*; import static java.lang.Integer.*; import static java.lang.Long.*; import static java.lang.Long.*; import static java.lang.Long.*; import static java.lang.Math.*; import static java.lang.Math.*; import static java.lang.Math.*; import static java.lang.System.*; import static java.lang.System.*; import static java.lang.System.*; public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		char[][] s = new char[3][];
		s[0] = sc.next().toCharArray();
		s[1] = sc.next().toCharArray();
		s[2] = sc.next().toCharArray();
		sc.close();
		int[] sp = new int[3]; 
		int abc = 0;
		int tmp = 0;
		while(sp[abc] != s[abc].length) {
			tmp = (int)(s[abc][sp[abc]] - 'a');
			sp[abc]++;
			abc=tmp;
		}
		out.println((char)('A'+abc));
	}
} Main public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		char[][] s = new char[3][];
		s[0] = sc.next().toCharArray();
		s[1] = sc.next().toCharArray();
		s[2] = sc.next().toCharArray();
		sc.close();
		int[] sp = new int[3]; 
		int abc = 0;
		int tmp = 0;
		while(sp[abc] != s[abc].length) {
			tmp = (int)(s[abc][sp[abc]] - 'a');
			sp[abc]++;
			abc=tmp;
		}
		out.println((char)('A'+abc));
	} main {
		int i,j;
		Scanner sc = new Scanner(in);
		char[][] s = new char[3][];
		s[0] = sc.next().toCharArray();
		s[1] = sc.next().toCharArray();
		s[2] = sc.next().toCharArray();
		sc.close();
		int[] sp = new int[3]; 
		int abc = 0;
		int tmp = 0;
		while(sp[abc] != s[abc].length) {
			tmp = (int)(s[abc][sp[abc]] - 'a');
			sp[abc]++;
			abc=tmp;
		}
		out.println((char)('A'+abc));
	} int i i j; j Scanner sc = new Scanner(in); sc new Scanner(in) char[][] s = new char[3][]; s new char[3][] 3 s[0] = sc.next().toCharArray() s[0] s 0 sc.next().toCharArray() sc.next().toCharArray sc.next() sc.next sc s[1] = sc.next().toCharArray() s[1] s 1 sc.next().toCharArray() sc.next().toCharArray sc.next() sc.next sc s[2] = sc.next().toCharArray() s[2] s 2 sc.next().toCharArray() sc.next().toCharArray sc.next() sc.next sc sc.close() sc.close sc int[] sp = new int[3]; sp new int[3] 3 int abc = 0; abc 0 int tmp = 0; tmp 0 while(sp[abc] != s[abc].length) {
			tmp = (int)(s[abc][sp[abc]] - 'a');
			sp[abc]++;
			abc=tmp;
		} sp[abc] != s[abc].length sp[abc] sp abc s[abc].length s[abc] s abc s[abc].length {
			tmp = (int)(s[abc][sp[abc]] - 'a');
			sp[abc]++;
			abc=tmp;
		} tmp = (int)(s[abc][sp[abc]] - 'a') tmp (int)(s[abc][sp[abc]] - 'a') s[abc][sp[abc]] s[abc] s abc sp[abc] sp abc 'a' sp[abc]++ sp[abc] sp abc abc=tmp abc tmp out.println((char)('A'+abc)) out.println out (char)('A'+abc) 'A' abc String[] args args public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		char[][] s = new char[3][];
		s[0] = sc.next().toCharArray();
		s[1] = sc.next().toCharArray();
		s[2] = sc.next().toCharArray();
		sc.close();
		int[] sp = new int[3]; 
		int abc = 0;
		int tmp = 0;
		while(sp[abc] != s[abc].length) {
			tmp = (int)(s[abc][sp[abc]] - 'a');
			sp[abc]++;
			abc=tmp;
		}
		out.println((char)('A'+abc));
	}
} public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		char[][] s = new char[3][];
		s[0] = sc.next().toCharArray();
		s[1] = sc.next().toCharArray();
		s[2] = sc.next().toCharArray();
		sc.close();
		int[] sp = new int[3]; 
		int abc = 0;
		int tmp = 0;
		while(sp[abc] != s[abc].length) {
			tmp = (int)(s[abc][sp[abc]] - 'a');
			sp[abc]++;
			abc=tmp;
		}
		out.println((char)('A'+abc));
	}
} Main
import java.util.*;
import java.io.PrintWriter;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		char[][] s = new char[3][];
		s[0] = sc.next().toCharArray();
		s[1] = sc.next().toCharArray();
		s[2] = sc.next().toCharArray();
		sc.close();
		int[] sp = new int[3]; 
		int abc = 0;
		int tmp = 0;
		while(sp[abc] != s[abc].length) {
			tmp = (int)(s[abc][sp[abc]] - 'a');
			sp[abc]++;
			abc=tmp;
		}
		out.println((char)('A'+abc));
	}
}
