#include <bits/stdc++.h> //biblioteka kotoraya vkluchaet vse v sebe

using namespace std;

int main(){

 freopen("input.txt", "r", stdin);
 string x;
 string winner;
 string winner1;
 map<string,int> m;
 map<string,int>:: iterator it;
 while(cin>>x){
  m[x]++;
  if(winner.size()<x.size()){
   winner=x;
  }
 }
 for(it=m.begin();it!=m.end();it++){
  int mval = INT_MIN; 
  if (mval < (*it).second)
   mval = (*it).second;
   winner1 = (*it).first;
 }

 cout << winner1 << " " << winner;


 return 0;
}