#include <bits/stdc++.h>
using namespace std;

int main() {
	ios_base::sync_with_stdio( false );

	string a;
	string b;
	map<string, int> mp;
	int x = 0;

	string s;
	while( cin >> s ) {
		mp[s] += 1;
		if( mp[s] > x ) {
			x = mp[s];
			a = s;
		}

		if( s.size() > b.size() ) {
			b = s;
		}
	}

	cout << a << ' ' << b << endl;
}

