#include <iostream>
#include <map>
#include <string>
#include <utility>
using namespace std;
int main() {
  map<string, int> word;
  string s, s1 = "", s2 = "";
  int a = 0;
  while (cin >> s)
    word[s]++;
  for (auto e : word) {
    if (a < e.second) s1 = e.first;
    if (s2.size() < e.first.size()) s2 = e.first;
  }
  cout << s1 << ' ' << s2 << endl;
  return 0;
}