#include <iostream>
#include <map>
using namespace std;

int main(void){
  map<string,int> mp;
  int len = 0;
  string s,t;
  while(cin >> s){
    ++mp[s];
    if(len < (int)s.size()){
      len = s.size();
      t = s;
    }
  }
  string u;
  for(map<string,int>::iterator it = mp.begin() ; it != mp.end() ; ++it){
    u = it->first;
  }
  cout << u << " " << t << endl;
  return 0;
}