#include <bits/stdc++.h>
#define int long long
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF (((ll)1<<31)-1)
#define eps LDBL_EPSILON
#define moder (1000000007)
#define pie acos(-1)
#define P std::pair<int,int>
#define prique priority_queue
#define ggr getchar();getchar();return 0;
using namespace std;
string s;
map<string,int> mp;
signed main(){
	int maw=0;
	string mw;
	while(cin>>s){
		mp[s]++;
		if(s.size()>maw){
			mw=s;
			maw=s.size();
		}
	}
	int ofw=0;
	string ow;
	for(pair<string,int> p:mp){
		if(p.second>ofw){
			ofw=p.second;
			ow=p.first;
		}
	}
	cout<<ow<<" "<<mw<<endl;
	return 0;
}
