#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<complex>
#include<map>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define EPS (1e-10)
using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef complex<double> P;

int main(){
  map<string,int> m;
  string str;
  string ans1 = "";
  string ans2 = "";
  int cnt = 0;
  while(cin>>str) m[str]++;
  FOR(it,m){
    if(it->f.size() > ans2.size())
      ans2 = it->f;
    if(cnt < it->s){
      ans1 = it->f;
      cnt  = it->s;
    }
  }
  cout << ans1 << " " << ans2 << endl;
  return 0;
}