#include <bits/stdc++.h>
using namespace std;
int as[100001];
int bs[100001];
int vs[200001][2];
int foods[200001];
int main() {
  memset(foods, 0, sizeof(foods));
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d%d", as + i, bs + i);
    vs[as[i]][0] = bs[i];
    vs[bs[i]][0] = as[i];
  }
  for (int i = 1; i <= 2 * n; i += 2) {
    vs[i][1] = i + 1;
    vs[i + 1][1] = i;
  }
  int next, nf, cur;
  for (int i = 1; i <= 2 * n; ++i) {
    if (foods[i]) continue;
    cur = i;
    foods[i] = 1;
    bool found = true;
    while (found) {
      found = false;
      for (int j = 0; !found && j < 2; ++j) {
        next = vs[cur][j];
        if (!foods[next]) {
          foods[next] = 3 - foods[cur];
          ;
          found = true;
          cur = next;
        }
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    printf("%d %d\n", foods[as[i]], foods[bs[i]]);
  }
}
