#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int A[200010];
  int fri[100010];
  for (int i = 0; i < N; i++) {
    int p, q;
    cin >> p >> q;
    fri[i] = p;
    A[p] = q;
    A[q] = p;
  }
  int res[200010] = {};
  for (int i = 1; i <= 2 * N; i++) {
    if (res[i] == 0) {
      int tmp = 1;
      int now = A[i];
      res[i] = tmp;
      tmp = 2;
      while (now != i) {
        if (res[A[now]] == 0) {
          res[now] = tmp;
          now = A[now];
          if (tmp == 1) {
            tmp = 2;
          } else {
            tmp = 1;
          }
        } else {
          res[now] = tmp;
          if (now % 2 == 1) {
            now++;
          } else {
            now--;
          }
          if (tmp == 1) {
            tmp = 2;
          } else {
            tmp = 1;
          }
        }
      }
    }
  }
  for (int i = 0; i < N; i++) {
    if (res[fri[i]] == 1) {
      cout << "1 2" << endl;
    } else {
      cout << "2 1" << endl;
    }
  }
  return 0;
}
