#include using namespace std; const int MAXN = 1e5 + 5; int fa[MAXN * 2]; unordered_map idMap; int idCounter = 0; pair ans[MAXN]; int find(int x) { if (fa[x] != x) { fa[x] = find(fa[x]); } return fa[x]; } int getID(const string& s) { if (!idMap.count(s)) { idMap[s] = idCounter++; } return idMap[s]; } int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; for (int i = 0; i < n; i++) { fa[i] = i; } bool impossible = false; for (int i = 0; i < n; i++) { string u; cin >> u; string s1 = u.substr(0, 1); string s2 = u.substr(1, 2); string s3 = u.substr(0, 2); string s4 = u.substr(2, 1); int id1 = getID(s1); int id2 = getID(s2); int id3 = getID(s3); int id4 = getID(s4); if (find(id1) != find(id2)) { fa[find(id1)] = find(id2); ans[i] = {s1, s2}; continue; } if (find(id3) != find(id4)) { fa[find(id3)] = find(id4); ans[i] = {s3, s4}; continue; } impossible = true; break; } if (impossible) { cout << "Impossible\n"; } else { for (int i = 0; i < n; i++) { cout << ans[i].first << " " << ans[i].second << '\n'; } } return 0; }