#include<stdio.h>
#include<string.h>
#define Maxn 1005
char s[Maxn / 4][33], a[33];
int f[Maxn / 4];
int main () {
	int t = 0, i, j, flag = 1, ff = 1;
	while (scanf("%s", a) != EOF) {
		memset(f, 0, sizeof(f));
		int max = 0, len = strlen(a);
		t++;
		if (len > max) {
			max = len;
			flag = t;
		}
		strcpy(s[t], a);
		f[t]++;
	}
	for (i = 1; i <= t; i++) {
		for (j = i; j <= t; j++) {
			if (!strcmp(s[i], s[j]))
				f[j]++;
		}
	}
	int Max = 0, flag2 = 1;
	for (i = 1; i <= t; i++) {
		if (f[i] > Max) {
			Max = f[i];
			flag2 = i;
		}
	}
	printf("%s %s\n", s[flag], s[flag2]);
	return 0;
}