#include #define _overload(_1,_2,_3,name,...) name #define _rep(i,n) _range(i,0,n) #define _range(i,a,b) for(int i=int(a);i=int(b);--i) #define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__) #define _all(arg) begin(arg),end(arg) #define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg)) #define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary) #define clr(a,b) memset((a),(b),sizeof(a)) #define bit(n) (1LL<<(n)) #define popcount(n) (__builtin_popcountll(n)) using namespace std; templatebool chmax(T &a, const T &b) { return (abool chmin(T &a, const T &b) { return (bEPS=1e-8 [-10000,10000]->EPS=1e-7 inline int sgn(const R& r){return(r > EPS)-(r < -EPS);} inline R sq(R x){return sqrt(max(x,0.0L));} const int dx[8]={1,0,-1,0,1,-1,-1,1}; const int dy[8]={0,1,0,-1,1,1,-1,-1}; // Problem Specific Parameter: string s[110]; int par[110]; int main(void){ int n; cin >> n; if(n>52){ puts("Impossible"); return 0; } rep(i,n) cin >> s[i]; rep(i,n) par[i]=-1; rep(i,n){ if(par[i]!=-1) continue; rep(j,2){ bool ok=true; int tmp[110]; rep(k,n) tmp[k]=par[k]; tmp[i]=j; queue q; q.push(i); while(ok and !q.empty()){ int cur=q.front(); q.pop(); string one=s[cur].substr(tmp[cur]?2:0,1); string two=s[cur].substr(tmp[cur]?0:1,2); //cout << cur << " " << one << " " << two << endl; rep(k,n){ if(k==cur) continue; int ban=0; if(tmp[k]==0) ban|=1; if(tmp[k]==1) ban|=2; if(s[k].substr(0,1)==one or s[k].substr(1,2)==two) ban|=2; if(s[k].substr(0,2)==two or s[k].substr(2,1)==one) ban|=1; if(ban==3){ ok=false; break; } if(ban!=0 and tmp[k]==-1){ if(ban==2) tmp[k]=1; if(ban==1) tmp[k]=0; q.push(k); } } } if(ok){ rep(k,n) par[k]=tmp[k]; break; } par[i]=-1; } if(par[i]==-1){ puts("Impossible"); return 0; } } rep(i,n){ if(par[i]==0) cout << s[i].substr(0,1) << " " << s[i].substr(1,2) << endl; else cout << s[i].substr(0,2) << " " << s[i].substr(2,1) << endl; } return 0; }