#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int color[2 * maxn], U[maxn], V[maxn], n;
vector<int> dt[maxn * 2];
void dfs(int u, int mau) {
  color[u] = mau;
  for (int i = 0; i <= (int)dt[u].size() - 1; i++) {
    int v = dt[u][i];
    if (!~color[v]) {
      dfs(v, 1 ^ mau);
    }
  }
}
int main() {
  scanf("%d", &n);
  int u, v;
  for (int i = 1; i <= n; i++) {
    dt[i * 2].push_back(i * 2 + 1);
    dt[i * 2 + 1].push_back(i * 2);
  }
  for (int i = 1; i <= n; i++) {
    scanf("%d %d", &u, &v);
    U[i] = u;
    V[i] = v;
    dt[u].push_back(v);
    dt[v].push_back(u);
  }
  for (int i = 1; i <= 2 * n; i++) color[i] = -1;
  for (int i = 1; i <= 2 * n; i++) {
    if (!~color[i]) {
      dfs(i, 0);
    }
  }
  for (int i = 1; i <= n; i++)
    printf("%d %d\n", color[U[i]] + 1, color[V[i]] + 1);
  return 0;
}
