#include<iostream>
#include<string>
#include<vector>

using namespace std;

int main()
{
	vector<string> words;

	string str,tmp,tmpl;
	int max=0;
	int maxl=0;

	while(cin>>str)
		words.push_back(str);
	for(int i=0;i<words.size();i++){
		int c=0;
		int cl=words.at(i).size();
		for(int j=i+1;j<words.size();j++){
			if(words.at(i)==words.at(j)){
				c++;
			}
		}
		if(c>max){
			max=c;
			tmp=words.at(i);
		}
		if(cl>maxl){
			maxl=cl;
			tmpl=words.at(i);
		}
	}

	cout<<tmp<<" "<<tmpl<<endl;
	return 0;
}