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

#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
typedef map<string, int> MAPSI;

int main() {

	string in,s;
	long long int  max_length = 0;
	string max_s;
	map<string,int> ms;
	while (getline(cin,s,' ')) {
		// getline???????????????????°?????????????????????????????????????
		if (s[s.size() - 1] == '\n'|| s[s.size() - 1] == '\r') {
			s.erase(s.length() - 1);
		}
		// ????????°???????????????
		if (max_length < s.length()) {
			max_s = s;
			max_length = s.length();
		}
		// ???????????????????????????
		if (ms.find(s)!=ms.end()) {
			ms[s]++;
		}
		else {
			ms.insert(make_pair(s, 1));
		}
	}

	// ??????
	string max_hindo_s;
	int max_hindo = 0;
	foreach_it(MAPSI, it, ms) {
		if (max_hindo < it->second) {
			max_hindo_s = it->first;
			max_hindo = it->second;
		}
	}
	cout << max_hindo_s << " " << max_s << endl;
	return 0;
}