#include <bits/stdc++.h>
using namespace std;
int a[200005];
int b[200005];
int u[100005], v[100005];
inline int inv(int p) { return (p & 1) ? (p - 1) : (p + 1); }
void run(int p, int w) {
  while (a[p] == 0) {
    a[p] = w + 1;
    a[inv(p)] = (w ^ 1) + 1;
    p = b[inv(p)];
  }
}
int main() {
  int n;
  while (scanf("%d", &n) == 1) {
    for (int i = 0; i < n; i++) {
      scanf("%d%d", &u[i], &v[i]);
      b[u[i]] = v[i];
      b[v[i]] = u[i];
    }
    memset(a, 0, sizeof(a));
    a[1] = 1;
    a[2 * n] = 2;
    run(b[1], 1);
    run(b[2 * n], 0);
    for (int i = 1; i <= 2 * n; i++)
      if (a[i] == 0) run(i, 0);
    for (int i = 0; i < n; i++) printf("%d %d\n", a[u[i]], a[v[i]]);
  }
}
