import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

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

		String[] s = {sc.next(), sc.next(), sc.next()};
		int p = 0;
		while (s[p].length() != 0) {
			int np = s[p].charAt(0) - 'a';
			s[p] = s[p].substring(1);
			p = np;
		}
		System.out.println((char)('A' + p));
	} main {
		Scanner sc = new Scanner(System.in);

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

