#include<iostream>
#include<fstream>
#include<sstream>
#include<cstdio>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdlib>
using namespace std;

int main(){
	char mat[50];
	map<string,int> table;
	int maxi=0;
	string longest="",most="";
	while(scanf("%s",mat)!=EOF){
		string word(mat);
		table[word]++;
		if(table[word]>maxi){
			maxi = table[word];
			most = word;
		}
		if(word.size()>longest.size()){
			longest = word;
		}
	}
	cout<<most<<" "<<longest<<endl;
	return 0;
}