#include <bits/stdc++.h>
using namespace std;
const int N = 200 * 1000 + 3;
int n, p[N], c[N];
pair<int, int> pp[N];
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x, y;
    assert(scanf("%d%d", &x, &y) == 2);
    x--, y--;
    p[x] = y;
    p[y] = x;
    pp[i] = make_pair(x, y);
  }
  memset(c, -1, sizeof(c));
  for (int i = 0; i < 2 * n; i++) {
    int v = i;
    while (c[v] == -1) {
      c[v] = 1;
      c[v ^ 1] = 2;
      v = p[v ^ 1];
    }
  }
  for (int i = 0; i < n; i++)
    printf("%d %d\n", c[pp[i].first], c[pp[i].second]);
  return 0;
}
