#include <bits/stdc++.h>
 
using namespace std;
 
/*-------------------------------*/
#define FOR(i, a, b) for(int i = (a); i < (b); i++) 
#define RFOR(i, a, b) for(int i = (b) - 1; i >= (a); i--)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define RREP(i, n) for(int i = (n) - 1; i >= 0; i--)
#define all(i) (i).begin(),(i).end()
#define pb push_back
#define mp make_pair 
 
typedef long long ll;
typedef pair<int, int> pint;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef vector<long long> llv;
typedef vector<pint> vpint;
typedef vector<string> vs;
/*-------------------------------*/
 
int main(void)
{
  vs s;
  string a, smax;
  cin >> smax;
  while (cin >> a){
    if (a.size() > smax.size()) smax = a;
    s.pb(a);
  }

  string x = s[0];
  int bcnt = 0;
  FOR(i, 0, s.size()){
    int cnt = 0;
    FOR(j, 0, s.size()){
      if (s[i] == s[j]) cnt++;
    }
    if (i == 0) bcnt = cnt;
    if (bcnt < cnt) x = s[i];
    bcnt = cnt;
  }
  cout << x << " " << smax << endl;

  return 0;
}