#include <iostream>
using namespace std;

int main(){
  string str[1000];
  int appear[1000];
  int i, j, n=0;
  int maxlen, maxleni;
  int maxappear, maxappeari;

  while(cin>>string[n]){
    for(i=0; i<string[n].size(); i++) string[n][i]=tolower(string[n][i]);
    n++;
  }
  maxlen=0;
  for(i=0; i<n; i++){
    if(maxlen<string[i].size()){
      maxlen=string[i].size();
      maxleni=i;
    }
  }
  for(i=0; i<n; i++) appear[i]=0;
  for(i=0; i<n; i++){
    if(string[i].empty()) continue;
    for(j=i+1; j<n; j++)
      if(string[i]==string[j]){
        appear[i]++;
        string[j][0]='\0';
      }
  }
  maxappear=0;
  for(i=0; i<n; i++){
    if(maxappear<appear[i]){
      maxappear=appear[i];
      maxappeari=i;
    }
  }
  cout<<string[maxappeari]<<" "<<string[maxlen]<<endl;

  return 0;
}