#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 7 + 200000;
int a[MAX_N], b[MAX_N];
int par[MAX_N];
int col[MAX_N];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &a[i], &b[i]);
    par[a[i]] = b[i];
    par[b[i]] = a[i];
  }
  memset(col, -1, sizeof(col));
  for (int i = 1; i <= 2 * n; i++)
    if (!~col[i]) {
      col[i] = 1;
      col[i + 1] = 2;
      for (int u = par[i + 1]; u != i; u = par[u]) {
        col[u] = 1;
        if (u & 1)
          u++;
        else
          u--;
        col[u] = 2;
      }
    }
  for (int i = 1; i <= n; i++) printf("%d %d\n", col[a[i]], col[b[i]]);
}
