#include <iostream>
#include <string>
#include <algorithm>
#include <map>
using namespace std; 
int main() { 
  int maxc=0, maxs=0, c;
  string s;  
  multimap<string, int> a; 
  multimap<string, int>::iterator it, mc, ms;
  while(cin >> s) {   
    c = a.count(s);  
    if(c!=0) a.insert(make_pair(s, c+1));  
    else a.insert(make_pair(s, 1));
  }  
  for(it=a.begin(); it!=a.end(); it++) { 
    if(it->second > maxc) {
      maxc = it->second;  
      mc = it;  
    }  
    if(it->first.size() > maxs) {  
      maxs = it->first.size();   
      ms = it;  
    } 
  }  
  cout << mc->first << " " << ms->first << endl; 
  return 0;
}
