import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String[] arr = new String[3];
        arr[0] = scanner.nextLine();
        arr[1] = scanner.nextLine();
        arr[2] = scanner.nextLine();

        char turn = 'a';
        while (arr[turn - 'a'].length() > 0) {
            String s = arr[turn - 'a'];
            char nextTurn = s.charAt(0);
            arr[turn - 'a'] = s.substring(1, s.length());
            turn = nextTurn;
        }
        System.out.printf("%c\n", 'A' + turn - 'a');
    }
} import java.util.*; util.* java class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String[] arr = new String[3];
        arr[0] = scanner.nextLine();
        arr[1] = scanner.nextLine();
        arr[2] = scanner.nextLine();

        char turn = 'a';
        while (arr[turn - 'a'].length() > 0) {
            String s = arr[turn - 'a'];
            char nextTurn = s.charAt(0);
            arr[turn - 'a'] = s.substring(1, s.length());
            turn = nextTurn;
        }
        System.out.printf("%c\n", 'A' + turn - 'a');
    }
} Main public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String[] arr = new String[3];
        arr[0] = scanner.nextLine();
        arr[1] = scanner.nextLine();
        arr[2] = scanner.nextLine();

        char turn = 'a';
        while (arr[turn - 'a'].length() > 0) {
            String s = arr[turn - 'a'];
            char nextTurn = s.charAt(0);
            arr[turn - 'a'] = s.substring(1, s.length());
            turn = nextTurn;
        }
        System.out.printf("%c\n", 'A' + turn - 'a');
    } main {
        Scanner scanner = new Scanner(System.in);
        String[] arr = new String[3];
        arr[0] = scanner.nextLine();
        arr[1] = scanner.nextLine();
        arr[2] = scanner.nextLine();

        char turn = 'a';
        while (arr[turn - 'a'].length() > 0) {
            String s = arr[turn - 'a'];
            char nextTurn = s.charAt(0);
            arr[turn - 'a'] = s.substring(1, s.length());
            turn = nextTurn;
        }
        System.out.printf("%c\n", 'A' + turn - 'a');
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) String[] arr = new String[3]; arr new String[3] 3 arr[0] = scanner.nextLine() arr[0] arr 0 scanner.nextLine() scanner.nextLine scanner arr[1] = scanner.nextLine() arr[1] arr 1 scanner.nextLine() scanner.nextLine scanner arr[2] = scanner.nextLine() arr[2] arr 2 scanner.nextLine() scanner.nextLine scanner char turn = 'a'; turn 'a' while (arr[turn - 'a'].length() > 0) {
            String s = arr[turn - 'a'];
            char nextTurn = s.charAt(0);
            arr[turn - 'a'] = s.substring(1, s.length());
            turn = nextTurn;
        } arr[turn - 'a'].length() > 0 arr[turn - 'a'].length() arr[turn - 'a'].length arr[turn - 'a'] arr turn - 'a' turn 'a' 0 {
            String s = arr[turn - 'a'];
            char nextTurn = s.charAt(0);
            arr[turn - 'a'] = s.substring(1, s.length());
            turn = nextTurn;
        } String s = arr[turn - 'a']; s arr[turn - 'a'] arr turn - 'a' turn 'a' char nextTurn = s.charAt(0); nextTurn s.charAt(0) s.charAt s 0 arr[turn - 'a'] = s.substring(1, s.length()) arr[turn - 'a'] arr turn - 'a' turn 'a' s.substring(1, s.length()) s.substring s 1 s.length() s.length s turn = nextTurn turn nextTurn System.out.printf("%c\n", 'A' + turn - 'a') System.out.printf System.out System System.out "%c\n" 'A' + turn - 'a' 'A' + turn 'A' turn 'a' String[] args args
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String[] arr = new String[3];
        arr[0] = scanner.nextLine();
        arr[1] = scanner.nextLine();
        arr[2] = scanner.nextLine();

        char turn = 'a';
        while (arr[turn - 'a'].length() > 0) {
            String s = arr[turn - 'a'];
            char nextTurn = s.charAt(0);
            arr[turn - 'a'] = s.substring(1, s.length());
            turn = nextTurn;
        }
        System.out.printf("%c\n", 'A' + turn - 'a');
    }
}
