#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

bool cmp(string &s1, string &s2){
	return s1.size() < s2.size(); 
}

int main() {
    vector<string> v;
    string s;
    while (getline(cin ,s)) {
        v.push_back(s);
    }
    vector<string> v1 = v;
    sort(v.begin(), v.end(), cmp);
    int min = v[0].size();
    int max = v[v.size() - 1].size();
    for (int i = 0; i < v1.size(); i++) {
        if (v1[i].size() == min) {
            cout << v1[i] << endl;
        }
    }
    for (int i = 0; i < v1.size(); i++) {
        if (v1[i].size() == max) {
            cout << v1[i] << endl;
        }
    }
    return 0;
}