#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
struct words{
string word;
int length;
};
bool cmp(words w1,words w2){
return w1.length<w2.length;
}
int main() {
string str;
vector<words> myvector;
while(cin>>str){
words oneword;
oneword.word=str;
oneword.length=str.length();
myvector.push_back(oneword);
char ch=getchar();
if(ch=='\n') break;
}
sort(myvector.begin(),myvector.end(),cmp);
int n=myvector.size();
cout<<myvector[n-1].word<<endl<<myvector[0].word;
return 0;
}