#include<iostream>
#include<cstring>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdio>
#include<cmath>
#define pb(in,tmp) in.push_back(tmp)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) loop(i,0,b)
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
using namespace std;
int main(){
string s;
vector<string>a;
vector<int>b,c;
while(cin>>s){
int no=-1;
rep(j,a.size())if(a[j]==s)no=j;
if(no+1)b[no]++;
else{
pb(a,s);
pb(b,0);
pb(c,s.size());
}
}
int m=0,mi=0;
rep(i,b.size())if(m<b[i]){m=b[i];mi=i;}
cout<<a[mi]<<" ";
m=mi=0;
rep(i,c.size())if(m<c[i]){m=c[i];mi=i;}
cout<<a[mi]<<endl;
}