#include<iostream>
#include<vector>
using namespace std;
#define rep(i,a) for(int i = 0 ; i < a ; i ++)
#define loop(i,a,b) for(int i = a ; i < b ; i ++)

int main(void){
  string s;
  string len = "";
  int aryi[32];
  string arys[32];
  int n = 0;
  rep(i,32)aryi[i] = 0;
  while(cin>>s){
    arys[n++] = s;
    if(s.size()>len.size())len=s;
  }
  int used = 0;
  int index = -1;
  rep(i,n){
    loop(j,i+1,n){
      if(arys[i] == arys[j]){
        aryi[i]++;
        if(used < aryi[i]){
          index = i;
        }
      }
    }
  }

  cout<<arys[index]<<" "<<len<<endl;

}