package yukicoder; import java.util.*; public class Q470 { static ArrayList[] g; @SuppressWarnings("unchecked") public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); if (n > 52) { System.out.println("Impossible"); return; } String[] u = new String[n]; for (int i = 0; i < n; ++i) { u[i] = sc.next(); } g = new ArrayList[2 * n]; for (int i = 0; i < g.length; ++i) { g[i] = new ArrayList<>(); } for (int i = 0; i < n; ++i) { for (int j = i + 1; j < n; ++j) { if (u[i].substring(0, 1).equals(u[j].substring(0, 1)) || u[i].substring(1, 3).equals(u[j].substring(1, 3))) { g[i].add(j + n); g[j].add(i + n); } if (u[i].substring(0, 1).equals(u[j].substring(2, 3)) || u[i].substring(1, 3).equals(u[j].substring(0, 2))) { g[i].add(j); g[n + j].add(n + i); } if (u[i].substring(0, 2).equals(u[j].substring(0, 2)) || u[i].substring(2, 3).equals(u[j].substring(2, 3))) { g[i + n].add(j); g[j + n].add(i); } if (u[i].substring(0, 2).equals(u[j].substring(1, 3)) || u[i].substring(2, 3).equals(u[j].substring(0, 1))) { g[i + n].add(j + n); g[j].add(i); } } } int V = 2 * n; vis = new boolean[V]; marked = new boolean[V]; cmp = new int[V]; low = new int[V]; id = new int[V]; for (int i = 0; i < V; ++i) { if (!marked[i]) { dfs(i); } } for (int i = 0; i < n; ++i) { if (cmp[i] == cmp[i + n]) { System.out.println("Impossible"); return; } } for (int i = 0; i < n; ++i) { if (cmp[i] < cmp[i + n]) { System.out.println(u[i].substring(0, 1) + " " + u[i].substring(1, 3)); } else { System.out.println(u[i].substring(0, 2) + " " + u[i].substring(2, 3)); } } } static ArrayDeque stack = new ArrayDeque<>(); static boolean[] vis; static int[] low; static int[] id; static int curId = 0; static boolean[] marked; static int[] cmp; static int col = 0; static void dfs(int cur) { vis[cur] = true; stack.addFirst(cur); id[cur] = curId++; low[cur] = id[cur]; for (int dst : g[cur]) { if (marked[dst]) continue; if (!vis[dst]) { dfs(dst); low[cur] = Math.min(low[cur], low[dst]); } else { low[cur] = Math.min(low[cur], id[dst]); } } if (id[cur] == low[cur]) { int v; do { v = stack.removeFirst(); cmp[v] = col; marked[v] = true; } while (v != cur); ++col; } return; } static void tr(Object... objects) { System.out.println(Arrays.deepToString(objects)); } }