#include <bits/stdc++.h>
using namespace std;
int x[1000050], y[1000050], a[1000050], f[1000050];
int main() {
  int n, i, j, k;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%d%d", &x[i], &y[i]);
    a[x[i]] = y[i];
    a[y[i]] = x[i];
  }
  for (i = 1; i <= 2 * n; i++)
    for (j = i, k = 0; !f[j]; k ^= 1) {
      f[j] = k + 1;
      if (k)
        j = ((j - 1) ^ 1) + 1;
      else
        j = a[j];
    }
  for (i = 1; i <= n; i++) printf("%d %d\n", f[x[i]], f[y[i]]);
  return 0;
}
