import std.stdio,std.string,std.conv;

int main()
{
	string[] s = readln.chomp.split(" ");
	string len_max = s[0],ans = s[0];
	int[string] map;
	int count_max = 1;

	foreach(i;0..(s.length))
	{
		if(len_max.length < s[i].length)
		{
			len_max = s[i];
		}
		map[s[i]]++;

		if(map[s[i]] > count_max)
		{
			count_max = map[s[i]];
			ans = s[i];
		}
	}
	writeln(ans," ",len_max);
	return 0;
}