#include <bits/stdc++.h>
const int N = 2000005;
int n, m, h[N], nxt[N], adj[N], u[N], v[N], t, col[N];
bool fl = 0;
inline void add(register int u, register int v) {
  nxt[++t] = h[u], h[u] = t, adj[t] = v;
  nxt[++t] = h[v], h[v] = t, adj[t] = u;
}
void fr(int &num) {
  num = 0;
  char c = getchar();
  int p = 1;
  while (c < '0' || c > '9') c == '-' ? p = -1, c = getchar() : c = getchar();
  while (c >= '0' && c <= '9') num = num * 10 + c - '0', c = getchar();
  num *= p;
}
inline void dfs(register int x) {
  if (fl) return;
  for (register int i = h[x]; i; i = nxt[i]) {
    if (col[adj[i]] == col[x]) {
      fl = 1;
      return;
    }
    if (!col[adj[i]]) col[adj[i]] = col[x] ^ 3, dfs(adj[i]);
  }
}
int main() {
  fr(n), m = n << 1;
  for (register int i = 1; i <= n; ++i) fr(u[i]), fr(v[i]), add(u[i], v[i]);
  for (register int i = 1; i <= n; ++i)
    add(2 * i - 1, 2 * i), add(2 * i, 2 * i - 1);
  for (register int i = 1; i <= m; ++i)
    if (!col[i]) col[i] = 1, dfs(i);
  dfs(1);
  if (fl) return puts("-1"), 0;
  for (register int i = 1; i <= n; ++i) printf("%d %d\n", col[u[i]], col[v[i]]);
  return 0;
}
