#include <bits/stdc++.h>
const bool debug = false;
using namespace std;
long long powmod(long long a, long long b, long long MOD) {
  long long res = 1;
  a %= MOD;
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % MOD;
    a = a * a % MOD;
  }
  return res;
}
void buginfo(const char* f, ...) {
  if (!debug) return;
  va_list al;
  va_start(al, f);
  vprintf(f, al);
  va_end(al);
}
const int maxn = 5e5 + 10;
int n, c[maxn], a[maxn], b[maxn];
vector<int> G[maxn];
void add_edge(int u, int v) {
  G[u].push_back(v);
  G[v].push_back(u);
}
void dfs(int u, int d) {
  if (c[u] != 0) return;
  c[u] = d;
  for (int i = 0; i < G[u].size(); ++i) {
    int v = G[u][i];
    dfs(v, 3 - d);
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d%d", a + i, b + i);
    add_edge(a[i], b[i]);
  }
  for (int i = 1; i < n; ++i) add_edge(2 * i, 2 * i + 1);
  for (int i = 1; i < 2 * n + 1; ++i) dfs(i, 1);
  for (int i = 0; i < n; ++i) {
    printf("%d %d\n", c[a[i]], c[b[i]]);
  }
  return 0 * printf("\n");
}
