#include <bits/stdc++.h>
using namespace std;
const int MAX = 2e5 + 20;
int A[MAX], B[MAX], type[MAX], cp[MAX], n;
vector<int> v[MAX];
queue<int> Q;
int pre(int x) { return x == 1 ? 2 * n : x - 1; }
int next(int x) { return x == 2 * n ? 1 : x + 1; }
bool BFS(int x) {
  while (!Q.empty()) Q.pop();
  Q.push(x);
  type[x] = 0;
  while (!Q.empty()) {
    int k = Q.front();
    Q.pop();
    for (int i = 0; i < v[k].size(); i++) {
      int to = v[k][i];
      if (type[to] != -1) continue;
      type[to] = (type[k] ^ 1);
      Q.push(to);
    }
  }
  return 1;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &A[i], &B[i]);
    cp[A[i]] = B[i];
    cp[B[i]] = A[i];
    v[A[i]].push_back(B[i]);
    v[B[i]].push_back(A[i]);
    v[2 * i].push_back(next(2 * i));
    v[next(2 * i)].push_back(2 * i);
  }
  for (int i = 1; i <= 2 * n; i++) type[i] = -1;
  for (int i = 1; i <= 2 * n; i++)
    if (type[i] == -1) BFS(i);
  for (int i = 1; i <= n; i++)
    printf("%d %d\n", type[A[i]] + 1, type[B[i]] + 1);
}
