unittest
{
	assert( [ "aca", "accc", "ca" ].parse.expand.solve == "A" );
	assert( [ "abcb", "aacb", "bccc" ].parse.expand.solve == "C" );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto a = input.front;
	input.popFront;
	auto b = input.front;
	input.popFront;
	auto c = input.front;
	return tuple( a, b, c );
}

auto solve( string a, string b, string c )
{
	auto ss = [ a, b, c ];
	auto t = 0L;
	while( 0 < ss[ t ].length )
	{
		auto n = ss[ t ][ 0 ] - 'a';
		ss[ t ].popFront;
		t = n;
	}
	
	auto ans = "A".dup;
	ans[ 0 ] += t;
	
	return ans;
}
