#include <iostream>
#include <cstring>
using namespace std;

int main(){
	int k = 0;
	int kazu = 0;
	int num[1000] = {0};
	string str[1000];
	string hindo;
	string mozisuu = "";
	while(cin >> str[k]){
		for(int i = 0; i < k; i++){
			if(str[k] == str[i]){
				num[i]++;
				break;
			}
		}
		k++;
	}
	for(int i = 0; i < k; i++){
		if(num[i] > kazu){
			kazu = num[i];
			hindo = str[i];
		}
		if(str[i].size() > mozisuu.size()){
			mozisuu = str[i];
		}
	}
	cout << hindo << " " << mozisuu << endl;
}