#include <bits/stdc++.h>
using namespace std;
int read() {
  int x = 0;
  char ch = getchar();
  for (; ch < '0' || ch > '9'; ch = getchar())
    ;
  for (; ch >= '0' && ch <= '9'; ch = getchar())
    x = (x << 3) + (x << 1) + (ch ^ 48);
  return x;
}
int n, x[200010], y[200010];
int ver[200010 << 1], ne[200010 << 1], head[200010], tot;
void add(int x, int y) {
  ver[++tot] = y;
  ne[tot] = head[x];
  head[x] = tot;
  ver[++tot] = x;
  ne[tot] = head[y];
  head[y] = tot;
}
int vis[200010];
void dfs(int u, int pre, int col) {
  vis[u] = col;
  for (int i = head[u], v; i; i = ne[i])
    if ((v = ver[i]) != pre && !vis[v]) dfs(v, u, col == 1 ? 2 : 1);
}
int main() {
  n = read();
  for (int i = 1; i <= n; i++) {
    x[i] = read();
    y[i] = read();
    add(x[i], y[i]);
  }
  for (int i = 1; i <= (n << 1); i += 2) add(i, i + 1);
  for (int i = 1; i <= (n << 1); i++)
    if (!vis[i]) dfs(i, 0, 1);
  for (int i = 1; i <= n; i++) printf("%d %d\n", vis[x[i]], vis[y[i]]);
  return 0;
}
