import java.util.*;
// warm-up
public class Main {
	// Making rookie mistakes.. Not an option
	static void solve() {
		Scanner sc = new Scanner(System.in);
		String[] a = {sc.next(),sc.next(),sc.next()};
		char ch = a[0].charAt(0); a[0]=a[0].substring(1);
		while (ch=='a'||ch=='b'||ch=='c') {
			switch(ch) {
				case 'a': ch=a[0].isEmpty() ? 'A' : a[0].charAt(0); if (ch!='A') a[0]=a[0].substring(1); break;
				case 'b': ch=a[1].isEmpty() ? 'B' : a[1].charAt(0); if (ch!='B') a[1]=a[1].substring(1); break;
				case 'c': ch=a[2].isEmpty() ? 'C' : a[2].charAt(0); if (ch!='C') a[2]=a[2].substring(1); break;
			}
		}
		System.out.println(ch);
		sc.close();
	}

	public static void main(String args[]) {
		solve();
	}

} import java.util.*; util.* java public class Main {
	// Making rookie mistakes.. Not an option
	static void solve() {
		Scanner sc = new Scanner(System.in);
		String[] a = {sc.next(),sc.next(),sc.next()};
		char ch = a[0].charAt(0); a[0]=a[0].substring(1);
		while (ch=='a'||ch=='b'||ch=='c') {
			switch(ch) {
				case 'a': ch=a[0].isEmpty() ? 'A' : a[0].charAt(0); if (ch!='A') a[0]=a[0].substring(1); break;
				case 'b': ch=a[1].isEmpty() ? 'B' : a[1].charAt(0); if (ch!='B') a[1]=a[1].substring(1); break;
				case 'c': ch=a[2].isEmpty() ? 'C' : a[2].charAt(0); if (ch!='C') a[2]=a[2].substring(1); break;
			}
		}
		System.out.println(ch);
		sc.close();
	}

	public static void main(String args[]) {
		solve();
	}

} Main // Making rookie mistakes.. Not an option
	static void solve() {
		Scanner sc = new Scanner(System.in);
		String[] a = {sc.next(),sc.next(),sc.next()};
		char ch = a[0].charAt(0); a[0]=a[0].substring(1);
		while (ch=='a'||ch=='b'||ch=='c') {
			switch(ch) {
				case 'a': ch=a[0].isEmpty() ? 'A' : a[0].charAt(0); if (ch!='A') a[0]=a[0].substring(1); break;
				case 'b': ch=a[1].isEmpty() ? 'B' : a[1].charAt(0); if (ch!='B') a[1]=a[1].substring(1); break;
				case 'c': ch=a[2].isEmpty() ? 'C' : a[2].charAt(0); if (ch!='C') a[2]=a[2].substring(1); break;
			}
		}
		System.out.println(ch);
		sc.close();
	} solve {
		Scanner sc = new Scanner(System.in);
		String[] a = {sc.next(),sc.next(),sc.next()};
		char ch = a[0].charAt(0); a[0]=a[0].substring(1);
		while (ch=='a'||ch=='b'||ch=='c') {
			switch(ch) {
				case 'a': ch=a[0].isEmpty() ? 'A' : a[0].charAt(0); if (ch!='A') a[0]=a[0].substring(1); break;
				case 'b': ch=a[1].isEmpty() ? 'B' : a[1].charAt(0); if (ch!='B') a[1]=a[1].substring(1); break;
				case 'c': ch=a[2].isEmpty() ? 'C' : a[2].charAt(0); if (ch!='C') a[2]=a[2].substring(1); break;
			}
		}
		System.out.println(ch);
		sc.close();
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String[] a = {sc.next(),sc.next(),sc.next()}; a {sc.next(),sc.next(),sc.next()} sc.next() sc.next sc sc.next() sc.next sc sc.next() sc.next sc char ch = a[0].charAt(0); ch a[0].charAt(0) a[0].charAt a[0] a 0 0 a[0]=a[0].substring(1) a[0] a 0 a[0].substring(1) a[0].substring a[0] a 0 1 while (ch=='a'||ch=='b'||ch=='c') {
			switch(ch) {
				case 'a': ch=a[0].isEmpty() ? 'A' : a[0].charAt(0); if (ch!='A') a[0]=a[0].substring(1); break;
				case 'b': ch=a[1].isEmpty() ? 'B' : a[1].charAt(0); if (ch!='B') a[1]=a[1].substring(1); break;
				case 'c': ch=a[2].isEmpty() ? 'C' : a[2].charAt(0); if (ch!='C') a[2]=a[2].substring(1); break;
			}
		} ch=='a'||ch=='b'||ch=='c' ch=='a'||ch=='b'||ch=='c' ch=='a' ch 'a' ch=='b' ch 'b' ch=='c' ch 'c' {
			switch(ch) {
				case 'a': ch=a[0].isEmpty() ? 'A' : a[0].charAt(0); if (ch!='A') a[0]=a[0].substring(1); break;
				case 'b': ch=a[1].isEmpty() ? 'B' : a[1].charAt(0); if (ch!='B') a[1]=a[1].substring(1); break;
				case 'c': ch=a[2].isEmpty() ? 'C' : a[2].charAt(0); if (ch!='C') a[2]=a[2].substring(1); break;
			}
		} switch(ch) {
				case 'a': ch=a[0].isEmpty() ? 'A' : a[0].charAt(0); if (ch!='A') a[0]=a[0].substring(1); break;
				case 'b': ch=a[1].isEmpty() ? 'B' : a[1].charAt(0); if (ch!='B') a[1]=a[1].substring(1); break;
				case 'c': ch=a[2].isEmpty() ? 'C' : a[2].charAt(0); if (ch!='C') a[2]=a[2].substring(1); break;
			} ch case 'a': 'a' case 'a': ch=a[0].isEmpty() ? 'A' : a[0].charAt(0) ch a[0].isEmpty() ? 'A' : a[0].charAt(0) a[0].isEmpty() a[0].isEmpty a[0] a 0 'A' a[0].charAt(0) a[0].charAt a[0] a 0 0 if (ch!='A') a[0]=a[0].substring(1); ch!='A' ch 'A' a[0]=a[0].substring(1) a[0] a 0 a[0].substring(1) a[0].substring a[0] a 0 1 break; case 'b': 'b' case 'b': ch=a[1].isEmpty() ? 'B' : a[1].charAt(0) ch a[1].isEmpty() ? 'B' : a[1].charAt(0) a[1].isEmpty() a[1].isEmpty a[1] a 1 'B' a[1].charAt(0) a[1].charAt a[1] a 1 0 if (ch!='B') a[1]=a[1].substring(1); ch!='B' ch 'B' a[1]=a[1].substring(1) a[1] a 1 a[1].substring(1) a[1].substring a[1] a 1 1 break; case 'c': 'c' case 'c': ch=a[2].isEmpty() ? 'C' : a[2].charAt(0) ch a[2].isEmpty() ? 'C' : a[2].charAt(0) a[2].isEmpty() a[2].isEmpty a[2] a 2 'C' a[2].charAt(0) a[2].charAt a[2] a 2 0 if (ch!='C') a[2]=a[2].substring(1); ch!='C' ch 'C' a[2]=a[2].substring(1) a[2] a 2 a[2].substring(1) a[2].substring a[2] a 2 1 break; System.out.println(ch) System.out.println System.out System System.out ch sc.close() sc.close sc public static void main(String args[]) {
		solve();
	} main {
		solve();
	} solve() solve String args[] args public class Main {
	// Making rookie mistakes.. Not an option
	static void solve() {
		Scanner sc = new Scanner(System.in);
		String[] a = {sc.next(),sc.next(),sc.next()};
		char ch = a[0].charAt(0); a[0]=a[0].substring(1);
		while (ch=='a'||ch=='b'||ch=='c') {
			switch(ch) {
				case 'a': ch=a[0].isEmpty() ? 'A' : a[0].charAt(0); if (ch!='A') a[0]=a[0].substring(1); break;
				case 'b': ch=a[1].isEmpty() ? 'B' : a[1].charAt(0); if (ch!='B') a[1]=a[1].substring(1); break;
				case 'c': ch=a[2].isEmpty() ? 'C' : a[2].charAt(0); if (ch!='C') a[2]=a[2].substring(1); break;
			}
		}
		System.out.println(ch);
		sc.close();
	}

	public static void main(String args[]) {
		solve();
	}

} public class Main {
	// Making rookie mistakes.. Not an option
	static void solve() {
		Scanner sc = new Scanner(System.in);
		String[] a = {sc.next(),sc.next(),sc.next()};
		char ch = a[0].charAt(0); a[0]=a[0].substring(1);
		while (ch=='a'||ch=='b'||ch=='c') {
			switch(ch) {
				case 'a': ch=a[0].isEmpty() ? 'A' : a[0].charAt(0); if (ch!='A') a[0]=a[0].substring(1); break;
				case 'b': ch=a[1].isEmpty() ? 'B' : a[1].charAt(0); if (ch!='B') a[1]=a[1].substring(1); break;
				case 'c': ch=a[2].isEmpty() ? 'C' : a[2].charAt(0); if (ch!='C') a[2]=a[2].substring(1); break;
			}
		}
		System.out.println(ch);
		sc.close();
	}

	public static void main(String args[]) {
		solve();
	}

} Main
import java.util.*;
// warm-up
public class Main {
	// Making rookie mistakes.. Not an option
	static void solve() {
		Scanner sc = new Scanner(System.in);
		String[] a = {sc.next(),sc.next(),sc.next()};
		char ch = a[0].charAt(0); a[0]=a[0].substring(1);
		while (ch=='a'||ch=='b'||ch=='c') {
			switch(ch) {
				case 'a': ch=a[0].isEmpty() ? 'A' : a[0].charAt(0); if (ch!='A') a[0]=a[0].substring(1); break;
				case 'b': ch=a[1].isEmpty() ? 'B' : a[1].charAt(0); if (ch!='B') a[1]=a[1].substring(1); break;
				case 'c': ch=a[2].isEmpty() ? 'C' : a[2].charAt(0); if (ch!='C') a[2]=a[2].substring(1); break;
			}
		}
		System.out.println(ch);
		sc.close();
	}

	public static void main(String args[]) {
		solve();
	}

}
