#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int a[3] = { 0 };
	a[0] = 1;
	int x, y;
	char al[4] = {"ABC"};
	char s[3];
	while (scanf("%c  %c %c", &s[0], &s[1], &s[2]) != EOF){

		if (s[0] == 'A'){
			x = 0;
		}
		if (s[0] == 'B'){
			x = 1;
		}
		if (s[0] == 'C'){
			x = 2;
		}
		if (s[2] == 'A'){
			y = 0;
		}
		if (s[2] == 'B'){
			y = 1;
		}
		if (s[2] == 'C'){
			y = 2;
		}
		swap(a[x], a[y]);
	}
	for (int i = 0; i < 3; i++){
		if (a[i]){
			cout << al[i] << endl;
			break;
		}
	}
}