unittest
{
	assert( [ "7", "beat", "vet", "beet", "bed", "vet", "bet", "beet" ].parse.expand.solve == "beet\nvet" );
	assert( [ "8", "buffalo", "buffalo", "buffalo", "buffalo", "buffalo", "buffalo", "buffalo", "buffalo" ].parse.expand.solve == "buffalo" );
	assert( [ "7", "bass", "bass", "kick", "kick", "bass", "kick", "kick" ].parse.expand.solve == "kick" );
	assert( [ "4", "ushi", "tapu", "nichia", "kun" ].parse.expand.solve == "kun\nnichia\ntapu\nushi" );
}



import std.algorithm;
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 n = input.front.to!( long );
	auto ss = new dchar[][ n ];
	foreach( ref s; ss )
	{
		input.popFront;
		s = input.front.to!( dchar[] );
	}
	return tuple( ss );
}

auto solve( dchar[][] ss )
{
	auto gs = ss.sort().group.array.sort!( ( a, b ) => b[ 1 ] < a[ 1 ] );
	auto fs = gs.filter!( ( a ) => gs.front[ 1 ] == a[ 1 ] ).map!( ( a ) => a[ 0 ] ).array.sort();
	return fs.join( "\n" );
}
