import java.util.Random;
import java.util.Scanner;
 


public class Main {
	private static Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	//static long mod =1000000007;
	//static 	ArrayList<Integer> cc = new ArrayList<>(100);
	
	
	
	public static void main(String[] args) {
		//int N=sc.nextInt();for(int i=0;i<N;i++) {}
		//int a[]=new int[N];
		StringBuffer a=new  StringBuffer(sc.next());
		StringBuffer b=new  StringBuffer(sc.next());

		StringBuffer c=new  StringBuffer(sc.next());

		
		
		
		StringBuffer v[]=new  StringBuffer[3];
		
		
		v[0]=a;
		v[1]=b;
		v[2]=c;
		//a 97 || //b 98 || //c 99 || 
		//A 65 || //B 66 || //C 67 || 
		char x=97;
		while(true) {
			if(v[x-97].length()==0) {
				x-=32;
				p(x+"");
				break;
			}
		//	p(x+"");
			char f=v[x-97].charAt(0);
			v[x-97].delete(0, 1);
			x=f;
			
			
		}
		
		}
		
		
	

	

	public static long gcd(long a, long b) {
        return b == 0 ? a: gcd(b, a % b);
	}
	public static long lcm(long n, long m) {
        return n / gcd(n, m) * m;
}
	
	

	


	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	
}
	 import java.util.Random; Random java.util import java.util.Scanner; Scanner java.util public class Main {
	private static Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	//static long mod =1000000007;
	//static 	ArrayList<Integer> cc = new ArrayList<>(100);
	
	
	
	public static void main(String[] args) {
		//int N=sc.nextInt();for(int i=0;i<N;i++) {}
		//int a[]=new int[N];
		StringBuffer a=new  StringBuffer(sc.next());
		StringBuffer b=new  StringBuffer(sc.next());

		StringBuffer c=new  StringBuffer(sc.next());

		
		
		
		StringBuffer v[]=new  StringBuffer[3];
		
		
		v[0]=a;
		v[1]=b;
		v[2]=c;
		//a 97 || //b 98 || //c 99 || 
		//A 65 || //B 66 || //C 67 || 
		char x=97;
		while(true) {
			if(v[x-97].length()==0) {
				x-=32;
				p(x+"");
				break;
			}
		//	p(x+"");
			char f=v[x-97].charAt(0);
			v[x-97].delete(0, 1);
			x=f;
			
			
		}
		
		}
		
		
	

	

	public static long gcd(long a, long b) {
        return b == 0 ? a: gcd(b, a % b);
	}
	public static long lcm(long n, long m) {
        return n / gcd(n, m) * m;
}
	
	

	


	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	
} Main private static Scanner sc = new Scanner(System.in); sc new Scanner(System.in) public static void main(String[] args) {
		//int N=sc.nextInt();for(int i=0;i<N;i++) {}
		//int a[]=new int[N];
		StringBuffer a=new  StringBuffer(sc.next());
		StringBuffer b=new  StringBuffer(sc.next());

		StringBuffer c=new  StringBuffer(sc.next());

		
		
		
		StringBuffer v[]=new  StringBuffer[3];
		
		
		v[0]=a;
		v[1]=b;
		v[2]=c;
		//a 97 || //b 98 || //c 99 || 
		//A 65 || //B 66 || //C 67 || 
		char x=97;
		while(true) {
			if(v[x-97].length()==0) {
				x-=32;
				p(x+"");
				break;
			}
		//	p(x+"");
			char f=v[x-97].charAt(0);
			v[x-97].delete(0, 1);
			x=f;
			
			
		}
		
		} main {
		//int N=sc.nextInt();for(int i=0;i<N;i++) {}
		//int a[]=new int[N];
		StringBuffer a=new  StringBuffer(sc.next());
		StringBuffer b=new  StringBuffer(sc.next());

		StringBuffer c=new  StringBuffer(sc.next());

		
		
		
		StringBuffer v[]=new  StringBuffer[3];
		
		
		v[0]=a;
		v[1]=b;
		v[2]=c;
		//a 97 || //b 98 || //c 99 || 
		//A 65 || //B 66 || //C 67 || 
		char x=97;
		while(true) {
			if(v[x-97].length()==0) {
				x-=32;
				p(x+"");
				break;
			}
		//	p(x+"");
			char f=v[x-97].charAt(0);
			v[x-97].delete(0, 1);
			x=f;
			
			
		}
		
		} StringBuffer a=new  StringBuffer(sc.next()); a new  StringBuffer(sc.next()) StringBuffer b=new  StringBuffer(sc.next()); b new  StringBuffer(sc.next()) StringBuffer c=new  StringBuffer(sc.next()); c new  StringBuffer(sc.next()) StringBuffer v[]=new  StringBuffer[3]; v new  StringBuffer[3] 3 v[0]=a v[0] v 0 a v[1]=b v[1] v 1 b v[2]=c v[2] v 2 c char x=97; x 97 while(true) {
			if(v[x-97].length()==0) {
				x-=32;
				p(x+"");
				break;
			}
		//	p(x+"");
			char f=v[x-97].charAt(0);
			v[x-97].delete(0, 1);
			x=f;
			
			
		} true {
			if(v[x-97].length()==0) {
				x-=32;
				p(x+"");
				break;
			}
		//	p(x+"");
			char f=v[x-97].charAt(0);
			v[x-97].delete(0, 1);
			x=f;
			
			
		} if(v[x-97].length()==0) {
				x-=32;
				p(x+"");
				break;
			} v[x-97].length()==0 v[x-97].length() v[x-97].length v[x-97] v x-97 x 97 0 {
				x-=32;
				p(x+"");
				break;
			} x-=32 x 32 p(x+"") p x+"" x "" break; char f=v[x-97].charAt(0); f v[x-97].charAt(0) v[x-97].charAt v[x-97] v x-97 x 97 0 v[x-97].delete(0, 1) v[x-97].delete v[x-97] v x-97 x 97 0 1 x=f x f String[] args args public static long gcd(long a, long b) {
        return b == 0 ? a: gcd(b, a % b);
	} gcd {
        return b == 0 ? a: gcd(b, a % b);
	} return b == 0 ? a: gcd(b, a % b); b == 0 ? a: gcd(b, a % b) b == 0 b 0 a gcd(b, a % b) gcd b a % b a b long a a long b b public static long lcm(long n, long m) {
        return n / gcd(n, m) * m;
} lcm {
        return n / gcd(n, m) * m;
} return n / gcd(n, m) * m; n / gcd(n, m) * m n / gcd(n, m) n gcd(n, m) gcd n m m long n n long m m static void p(String ans) {System.out.println(ans);} p {System.out.println(ans);} System.out.println(ans) System.out.println System.out System System.out ans String ans ans static void p(int ans) {System.out.println(ans);} p {System.out.println(ans);} System.out.println(ans) System.out.println System.out System System.out ans int ans ans static void p() {System.out.println();} p {System.out.println();} System.out.println() System.out.println System.out System System.out static void p(long ans) {System.out.println(ans);} p {System.out.println(ans);} System.out.println(ans) System.out.println System.out System System.out ans long ans ans static void p(double ans) {System.out.println(ans);} p {System.out.println(ans);} System.out.println(ans) System.out.println System.out System System.out ans double ans ans public class Main {
	private static Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	//static long mod =1000000007;
	//static 	ArrayList<Integer> cc = new ArrayList<>(100);
	
	
	
	public static void main(String[] args) {
		//int N=sc.nextInt();for(int i=0;i<N;i++) {}
		//int a[]=new int[N];
		StringBuffer a=new  StringBuffer(sc.next());
		StringBuffer b=new  StringBuffer(sc.next());

		StringBuffer c=new  StringBuffer(sc.next());

		
		
		
		StringBuffer v[]=new  StringBuffer[3];
		
		
		v[0]=a;
		v[1]=b;
		v[2]=c;
		//a 97 || //b 98 || //c 99 || 
		//A 65 || //B 66 || //C 67 || 
		char x=97;
		while(true) {
			if(v[x-97].length()==0) {
				x-=32;
				p(x+"");
				break;
			}
		//	p(x+"");
			char f=v[x-97].charAt(0);
			v[x-97].delete(0, 1);
			x=f;
			
			
		}
		
		}
		
		
	

	

	public static long gcd(long a, long b) {
        return b == 0 ? a: gcd(b, a % b);
	}
	public static long lcm(long n, long m) {
        return n / gcd(n, m) * m;
}
	
	

	


	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	
} public class Main {
	private static Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	//static long mod =1000000007;
	//static 	ArrayList<Integer> cc = new ArrayList<>(100);
	
	
	
	public static void main(String[] args) {
		//int N=sc.nextInt();for(int i=0;i<N;i++) {}
		//int a[]=new int[N];
		StringBuffer a=new  StringBuffer(sc.next());
		StringBuffer b=new  StringBuffer(sc.next());

		StringBuffer c=new  StringBuffer(sc.next());

		
		
		
		StringBuffer v[]=new  StringBuffer[3];
		
		
		v[0]=a;
		v[1]=b;
		v[2]=c;
		//a 97 || //b 98 || //c 99 || 
		//A 65 || //B 66 || //C 67 || 
		char x=97;
		while(true) {
			if(v[x-97].length()==0) {
				x-=32;
				p(x+"");
				break;
			}
		//	p(x+"");
			char f=v[x-97].charAt(0);
			v[x-97].delete(0, 1);
			x=f;
			
			
		}
		
		}
		
		
	

	

	public static long gcd(long a, long b) {
        return b == 0 ? a: gcd(b, a % b);
	}
	public static long lcm(long n, long m) {
        return n / gcd(n, m) * m;
}
	
	

	


	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	
} Main
import java.util.Random;
import java.util.Scanner;
 


public class Main {
	private static Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	//static long mod =1000000007;
	//static 	ArrayList<Integer> cc = new ArrayList<>(100);
	
	
	
	public static void main(String[] args) {
		//int N=sc.nextInt();for(int i=0;i<N;i++) {}
		//int a[]=new int[N];
		StringBuffer a=new  StringBuffer(sc.next());
		StringBuffer b=new  StringBuffer(sc.next());

		StringBuffer c=new  StringBuffer(sc.next());

		
		
		
		StringBuffer v[]=new  StringBuffer[3];
		
		
		v[0]=a;
		v[1]=b;
		v[2]=c;
		//a 97 || //b 98 || //c 99 || 
		//A 65 || //B 66 || //C 67 || 
		char x=97;
		while(true) {
			if(v[x-97].length()==0) {
				x-=32;
				p(x+"");
				break;
			}
		//	p(x+"");
			char f=v[x-97].charAt(0);
			v[x-97].delete(0, 1);
			x=f;
			
			
		}
		
		}
		
		
	

	

	public static long gcd(long a, long b) {
        return b == 0 ? a: gcd(b, a % b);
	}
	public static long lcm(long n, long m) {
        return n / gcd(n, m) * m;
}
	
	

	


	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	
}
	
