# include "bits/stdc++.h" using namespace std; using LL = long long; using ULL = unsigned long long; const double PI = acos(-1); templateconstexpr T INF() { return ::std::numeric_limits::max(); } templateconstexpr T HINF() { return INF() / 2; } template T_char TL(T_char cX) { return tolower(cX); }; template T_char TU(T_char cX) { return toupper(cX); }; typedef pair pii; const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 }; const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 }; int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; } int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; } int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; } LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); }; LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; }; # define ALL(qpqpq) (qpqpq).begin(),(qpqpq).end() # define UNIQUE(wpwpw) sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end()) # define LOWER(epepe) transform(ALL((epepe)),(epepe).begin(),TL) # define UPPER(rprpr) transform(ALL((rprpr)),(rprpr).begin(),TU) # define FOR(i,tptpt,ypypy) for(LL i=(tptpt);i<(ypypy);i++) # define REP(i,upupu) FOR(i,0,upupu) # define INIT std::ios::sync_with_stdio(false);std::cin.tie(0) struct SCC{ private: int v; vector> G; //グラフの隣接リスト表現 vector> rG; //辺の向きを逆にしたグラフ vector vs; //帰りがけ順の並び vector used; //すでに調べたか public: vector cmp; //属する競連結成分のトポロジカル順序 SCC(){ } SCC(int V){ v = V; G.resize(v); rG.resize(v); used.resize(v, false); cmp.resize(v, 0); } void init(int V){ v = V; G.resize(v); rG.resize(v); used.resize(v, false); cmp.resize(v, 0); } void add_edge(int f, int t){ G[f].emplace_back(t); rG[t].emplace_back(f); } void dfs(int cur){ used[cur] = true; for (int i = 0; i < (int)G[cur].size(); i++) { if (!used[G[cur][i]])dfs(G[cur][i]); } vs.emplace_back(cur); } void rdfs(int cur, int k) { used[cur] = true; cmp[cur] = k; for (int i = 0; i < (int)rG[cur].size(); i++) { if (!used[rG[cur][i]])rdfs(rG[cur][i], k); } } int scc() { vs.clear(); for (int i = 0; i < v; i++) { if (!used[i])dfs(i); } used.assign(v, 0); int k = 0; for (int i = vs.size() - 1; i >= 0; i--) { if (!used[vs[i]])rdfs(vs[i], k++); } return k; } }; struct two_sat{ private: int v; SCC sc; public: vector val; two_sat(int V){ v = V*2; val.resize(v/2); sc.init(v); } void add_edge(int f, int t){ sc.add_edge((f + v/2)%v, t); sc.add_edge((t + v/2)%v, f); } bool sat(){ sc.scc(); for(int i = 0;i < v/2;i++){ if(sc.cmp[i] == sc.cmp[i + v/2])return false; } for(int i = 0;i < v/2;i++){ val[i] = sc.cmp[i] > sc.cmp[i + v/2]; } return true; } }; int n; string s[101010]; int main(){ cin >> n; REP(i, n){ cin >> s[i]; } if(n > 52){ cout << "Impossible" << endl; return 0; } two_sat ts(n); REP(y, n)REP(x, y){ if(s[y].substr(0, 1)==s[x].substr(0, 1) || s[y].substr(1, 2)==s[x].substr(1, 2)) ts.add_edge(y + n, x + n); if(s[y].substr(0, 1)==s[x].substr(2, 1) || s[y].substr(1, 2)==s[x].substr(0, 2)) ts.add_edge(y + n, x); if(s[y].substr(2, 1)==s[x].substr(0, 1) || s[y].substr(0, 2)==s[x].substr(1, 2)) ts.add_edge(y, x + n); if(s[y].substr(2, 1)==s[x].substr(2, 1) || s[y].substr(0, 2)==s[x].substr(0, 2)) ts.add_edge(y, x); } if(!ts.sat()){ cout << "Impossible" << endl; return 0; } REP(i, n){ if(ts.val[i] == 1)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; } }