var max = "";
var map = {};

process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(input) {
  input = input.replace("\n", "");
  var arr = input.split(" ");
  for (var i in arr) {
    if (map[arr[i]] === undefined || map[arr[i]] === null) {
      map[arr[i]] = 0;
    } else {
      map[arr[i]]++;
    }
    if(max.length<arr[i].length) max = arr[i];
  }
});
process.stdin.on('end', function() {
  var keys = Object.keys(map);
  var m = keys.pop();
  for (var k in keys) {
    k = keys[k];
    if(map[m]<map[k]) m = k;
  }
  console.log(m, max);
});