#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, b1, b2;
  cin >> n;
  int a[n][2];
  int g[2 * n];
  for (int i = 0; i < n; i++) {
    cin >> b1 >> b2;
    b1--;
    b2--;
    a[i][0] = b1;
    a[i][1] = b2;
    g[b1] = b2;
    g[b2] = b1;
  }
  int f[2 * n];
  for (int i = 0; i < 2 * n; i = i + 2) {
    f[i] = i + 1;
    f[i + 1] = i;
  }
  int b[2 * n];
  for (int i = 0; i < 2 * n; i++) b[i] = 0;
  for (int i = 0; i < 2 * n; i++) {
    if (!b[i]) {
      b[g[i]] = 1;
      b[i] = 2;
      b[f[i]] = 1;
      int curr = g[f[i]];
      while (!b[curr]) {
        b[curr] = 2;
        b[f[curr]] = 1;
        curr = g[f[curr]];
      }
    }
  }
  for (int i = 0; i < n; i++) {
    cout << b[a[i][0]] << " " << b[a[i][1]] << endl;
  }
}
