#include "bits/stdc++.h" using namespace std; struct text { char array[1000]; int length; int order; }; bool cmp(text t1, text t2) { if (t1.length < t2.length) { return true; } else if (t1.length == t2.length) { if (t1.order < t2.order) { return true; } else{ return false; } } else { return false; } } int main() { string str; vector<text> v; int length = 0; int order = 0; while (getline(cin,str)) { length = str.size(); text t1; strcpy(t1.array, str.c_str()); t1.length = length; t1.order = order; v.push_back(t1); order++; } sort(v.begin(), v.end(), cmp); int max = v[0].length; int min = v[v.size() - 1].length; for (int i = 0; i < v.size(); ++i) { if (v[i].length == max || v[i].length == min) { cout << v[i].array << endl; } } }