#include <bits/stdc++.h>
int d[300000], r[300000], x[300000], y[300000];
int i, j, k, n;
int main() {
  scanf("%d", &n);
  for (i = 1; i <= n; i++)
    scanf("%d%d", &x[i], &y[i]), r[x[i]] = y[i], r[y[i]] = x[i];
  for (i = 1; i <= 2 * n; i++)
    for (j = i, k = 0; !d[j]; j = k ? ((j - 1) ^ 1) + 1 : r[j], k = 1 - k)
      d[j] = 2 - k;
  for (i = 1; i <= n; i++) printf("%d %d\n", d[x[i]], d[y[i]]);
  return 0;
}
