#include <bits/stdc++.h>
struct edge {
  int v, x;
} e[200001 << 2];
int h[200001], a[200001], b[200001], c[200001], t, n;
char ch;
inline void read(int& x) {
  for (x = 0; (ch = getchar()) < '0' || ch > '9';)
    ;
  do x = x * 10 + ch - '0';
  while ((ch = getchar()) >= '0' && ch <= '9');
}
inline void adde(int u, int v) {
  e[++t].v = v, e[t].x = h[u], h[u] = t, e[++t].v = u, e[t].x = h[v], h[v] = t;
}
bool check(int u, int k) {
  c[u] = k;
  for (int i = h[u]; i; i = e[i].x) {
    if (c[e[i].v]) {
      if (c[e[i].v] == k) return false;
    } else if (!check(e[i].v, 3 - k))
      return false;
  }
  return true;
}
int main() {
  read(n);
  for (int i = 1; i <= n; i++)
    read(a[i]), read(b[i]), adde(a[i], b[i]), adde((i << 1) - 1, i << 1);
  for (int i = 1; i <= n << 1; i++) {
    if (!c[i] && !check(i, 1)) {
      puts("-1");
      return 0;
    }
  }
  for (int i = 1; i <= n; i++) printf("%d %d\n", c[a[i]], c[b[i]]);
  return 0;
}
