#include <iostream>
using namespace std ;

int main()
{
	char get[1000][40] ;
	char mode[40] ;
	char longest[40] ;

	int count = 0 ;
	int lest = -1 ;
	
	int tmp = 0 ;

	int most = 0 ;
	int mnum = -1 ;

	int i = 0 ;

	while( cin >> get[i] )
	{
		if( count < strlen(get[i]) )
		{
			count = strlen(get[i]) ;
			lest = i ;
		}

		for( int j = (i-1) ; j >= 0 ;  j -- )
		{
			if( strcmp( get[i], get[j] ) == 0 )
			{
				tmp ++ ;
			}
		}
		tmp = 0 ;

		if( most < tmp )
		{
			most = tmp ;
			mnum = i ;
		}

		i ++ ;
	}

	cout << get[mnum] << " " << get[lest] ;

	return 0 ;
}