#!/bin/sh
read aa
read bb
read cc
cnta=0
cntb=0
cntc=0

a ()
{
	check=${aa:0:1}
	aa=${aa/?/}
	now=A
}
b ()
{
	check=${bb:0:1}
	bb=${bb/?/}
	now=B
}
c ()
{
	check=${cc:0:1}
	cc=${cc/?/}
	now=C
}

a

while :
do
	ans=$now
	case ${check} in
		a)
			a
		;;
		b)
			b
		;;
		c)
			c
		;;
		*)
			break
		;;
	esac
done
echo $ans
