import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner stdin = new Scanner(System.in);
        
        Map<Character, String> s = new HashMap<>();
        s.put('a', stdin.nextLine());
        s.put('b', stdin.nextLine());
        s.put('c', stdin.nextLine());
        
        char turn = 'a';
        while (!s.get(turn).isEmpty()) {
            String t = s.get(turn);
            s.put(turn, t.substring(1));
            turn = t.charAt(0);
        }
        
        System.out.println(Character.toUpperCase(turn));
    }
} import java.util.HashMap; HashMap java.util import java.util.Map; Map java.util import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner stdin = new Scanner(System.in);
        
        Map<Character, String> s = new HashMap<>();
        s.put('a', stdin.nextLine());
        s.put('b', stdin.nextLine());
        s.put('c', stdin.nextLine());
        
        char turn = 'a';
        while (!s.get(turn).isEmpty()) {
            String t = s.get(turn);
            s.put(turn, t.substring(1));
            turn = t.charAt(0);
        }
        
        System.out.println(Character.toUpperCase(turn));
    }
} Main public static void main(String[] args) {
        Scanner stdin = new Scanner(System.in);
        
        Map<Character, String> s = new HashMap<>();
        s.put('a', stdin.nextLine());
        s.put('b', stdin.nextLine());
        s.put('c', stdin.nextLine());
        
        char turn = 'a';
        while (!s.get(turn).isEmpty()) {
            String t = s.get(turn);
            s.put(turn, t.substring(1));
            turn = t.charAt(0);
        }
        
        System.out.println(Character.toUpperCase(turn));
    } main {
        Scanner stdin = new Scanner(System.in);
        
        Map<Character, String> s = new HashMap<>();
        s.put('a', stdin.nextLine());
        s.put('b', stdin.nextLine());
        s.put('c', stdin.nextLine());
        
        char turn = 'a';
        while (!s.get(turn).isEmpty()) {
            String t = s.get(turn);
            s.put(turn, t.substring(1));
            turn = t.charAt(0);
        }
        
        System.out.println(Character.toUpperCase(turn));
    } Scanner stdin = new Scanner(System.in); stdin new Scanner(System.in) Map<Character, String> s = new HashMap<>(); s new HashMap<>() s.put('a', stdin.nextLine()) s.put s 'a' stdin.nextLine() stdin.nextLine stdin s.put('b', stdin.nextLine()) s.put s 'b' stdin.nextLine() stdin.nextLine stdin s.put('c', stdin.nextLine()) s.put s 'c' stdin.nextLine() stdin.nextLine stdin char turn = 'a'; turn 'a' while (!s.get(turn).isEmpty()) {
            String t = s.get(turn);
            s.put(turn, t.substring(1));
            turn = t.charAt(0);
        } !s.get(turn).isEmpty() s.get(turn).isEmpty() s.get(turn).isEmpty s.get(turn) s.get s turn {
            String t = s.get(turn);
            s.put(turn, t.substring(1));
            turn = t.charAt(0);
        } String t = s.get(turn); t s.get(turn) s.get s turn s.put(turn, t.substring(1)) s.put s turn t.substring(1) t.substring t 1 turn = t.charAt(0) turn t.charAt(0) t.charAt t 0 System.out.println(Character.toUpperCase(turn)) System.out.println System.out System System.out Character.toUpperCase(turn) Character.toUpperCase Character turn String[] args args public class Main {
    public static void main(String[] args) {
        Scanner stdin = new Scanner(System.in);
        
        Map<Character, String> s = new HashMap<>();
        s.put('a', stdin.nextLine());
        s.put('b', stdin.nextLine());
        s.put('c', stdin.nextLine());
        
        char turn = 'a';
        while (!s.get(turn).isEmpty()) {
            String t = s.get(turn);
            s.put(turn, t.substring(1));
            turn = t.charAt(0);
        }
        
        System.out.println(Character.toUpperCase(turn));
    }
} public class Main {
    public static void main(String[] args) {
        Scanner stdin = new Scanner(System.in);
        
        Map<Character, String> s = new HashMap<>();
        s.put('a', stdin.nextLine());
        s.put('b', stdin.nextLine());
        s.put('c', stdin.nextLine());
        
        char turn = 'a';
        while (!s.get(turn).isEmpty()) {
            String t = s.get(turn);
            s.put(turn, t.substring(1));
            turn = t.charAt(0);
        }
        
        System.out.println(Character.toUpperCase(turn));
    }
} Main
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner stdin = new Scanner(System.in);
        
        Map<Character, String> s = new HashMap<>();
        s.put('a', stdin.nextLine());
        s.put('b', stdin.nextLine());
        s.put('c', stdin.nextLine());
        
        char turn = 'a';
        while (!s.get(turn).isEmpty()) {
            String t = s.get(turn);
            s.put(turn, t.substring(1));
            turn = t.charAt(0);
        }
        
        System.out.println(Character.toUpperCase(turn));
    }
}
