#include #include using namespace std; using ll = long long; #define rep(i,n) for(int i=0;i<(int)(n);i++) using S = pair; S op(S a,S b){ if(a.first!=b.first) return min(a,b); return max(a,b); } S e(){ return {'z'+1,-1}; } using segtree = atcoder::segtree; vector f(string s){ int n=s.size(); vector rt(n); rep(i,n) rt.at(i)={s.at(i),i}; return rt; } int main(){ int n; cin>>n; vector s(n); rep(i,n) cin>>s.at(i); for(auto &x:s){ segtree seg(f(x)); int m=x.size(); int flg=0; rep(i,m){ S a=seg.prod(i+1,m); if(x.at(i)>a.first){ swap(x.at(i),x.at(a.second)); flg=2; break; }else if(x.at(i)==a.first){ flg=1; } } if(!flg){ swap(x.at(m-1),x.at(m-2)); } } map mp; for(auto x:s){ mp[x]++; } string mn=mp.begin()->first; rep(i,n){ if(mn==s.at(i)) cout<