#include <bits/stdc++.h>
using namespace std;
const int MAXN = 220000;
int a[MAXN], b[MAXN], c[MAXN];
vector<int> g[MAXN];
void dfs(int u, int t) {
  c[u] = t;
  for (int v : g[u])
    if (!c[v]) dfs(v, t ^ 3);
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    g[2 * i].push_back(2 * i - 1);
    g[2 * i - 1].push_back(2 * i);
  }
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &a[i], &b[i]);
    g[a[i]].push_back(b[i]);
    g[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;
}
