import std.stdio, std.array, std.string, std.conv, std.algorithm; import std.typecons, std.range, std.random, std.math, std.container; import std.numeric, std.bigint, core.bitop, core.stdc.stdio, std.ascii; int N; int[] ans; string[] U; bool[string] used; bool dfs(int p) { if (p > N - 1) return true; string s0 = U[p][0].to!string; string s12 = U[p][1..3].to!string; string s01 = U[p][0..2].to!string; string s2 = U[p][2].to!string; if (!used[s0] && !used[s12]) { used[s0] = true; used[s12] = true; ans[p] = 0; if (dfs(p+1)) return true; used[s0] = false; used[s12] = false; } if (!used[s01] && !used[s2]) { used[s01] = true; used[s2] = true; ans[p] = 1; if (dfs(p+1)) return true; used[s01] = false; used[s2] = false; } return false; } void main() { N = readln.chomp.to!int; ans = new int[](N); U = new string[](N); foreach (i; 0..N) U[i] = readln.chomp; foreach (c1; letters) { used[c1.to!string] = false; foreach (c2; letters) used[c1.to!string ~ c2.to!string] = false; } if (dfs(0)) { foreach (i; 0..N) { if (ans[i] == 0) writeln(U[i][0], " ", U[i][1..3]); else writeln(U[i][0..2], " ", U[i][2]); } } else writeln("Impossible"); }