#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int a[N], b[N], c[2 * N];
vector<int> e[2 * N];
void dfs(int v, int p) {
  c[v] = p;
  for (auto u : e[v]) {
    if (!c[u]) dfs(u, 3 - p);
  }
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d%d", a + i, b + i);
  for (int i = 1; i <= n; i++) {
    e[i * 2].push_back(i * 2 - 1);
    e[i * 2 - 1].push_back(i * 2);
    e[a[i]].push_back(b[i]);
    e[b[i]].push_back(a[i]);
  }
  for (int i = 1; i <= 2 * n; i++)
    if (!c[i]) dfs(i, 1);
  for (int i = 1; i <= n; i++) printf("%d %d\n", c[a[i]], c[b[i]]);
  return 0;
}
