#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 5;
int n;
int col[MAXN];
int h[MAXN], tot;
struct edge {
  int to, nxt;
} e[MAXN << 2];
void add(int x, int y) {
  e[++tot] = (edge){y, h[x]};
  h[x] = tot;
}
void dfs(int x, int typ = 1) {
  col[x] = typ + 1;
  for (int u = h[x]; u; u = e[u].nxt)
    if (!col[e[u].to]) dfs(e[u].to, typ ^ 1);
}
int A[MAXN], B[MAXN];
int main() {
  int i, j, k;
  int x, y;
  scanf("%d", &n);
  for (i = 1; i <= n; ++i) {
    scanf("%d%d", &x, &y);
    A[i] = x, B[i] = y;
    add(x, y), add(y, x);
  }
  for (i = 1; i <= n; ++i) add(i * 2, i * 2 - 1), add(i * 2 - 1, i * 2);
  for (i = 1; i <= (n << 1); ++i)
    if (!col[i]) dfs(i);
  for (i = 1; i <= n; ++i) printf("%d %d\n", col[A[i]], col[B[i]]);
  return 0;
}
