//0029 English Sentence
//pêÌ¶ÍÅo»·éPêðÇÝæèAo»pxªÅà¢PêÆAàÁÆà·¢PêðoÍµÄI¹¹æ
//üÍf[^ÍAAt@xbgÆXy[XÌÝªÜÜêé
//¶ÍÌ¶Í1000¶ÈºÅA1PêÌ·³Í32¶ÈºÅ·
//Ü½Ao»pxªÅà¢PêÆÅà·¢PêÍA»ê¼ê¶ÉêÂµ©¶ÝµÈ¢

#include<iostream>
#include<string>
#include<map>
#include<limits>
#include<algorithm>
using namespace std;

int main(void)
{
	typedef map<string, int> Map;
	Map m;
	string str;
	Map::iterator s;
	int maxSize = numeric_limits<int>::min();
	while( cin >> str)
	{
		m[str]++;
		if( maxSize < (int)str.size())
		{
			maxSize = str.size();
			s = m.find(str);
		}
	}
	
	Map::iterator mode = m.begin();
	for(map<string, int>::iterator ite = m.begin();
		ite != m.end();
		++ite)
	{
		if(mode->second < ite->second)
			mode = ite;
	}
	cout << mode->first << ' ' << s->first << endl;
	return 0;
}