#include <bits/stdc++.h>
using namespace std;
pair<int, int> v[100010];
int p[200010], food[200010];
bool ap[200010];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d %d", &v[i].first, &v[i].second);
    p[v[i].first] = v[i].second;
    p[v[i].second] = v[i].first;
  }
  for (int i = 1; i <= 2 * n; ++i)
    if (!ap[i]) {
      int ind = i, m = 0;
      for (; !ap[ind];) {
        ap[ind] = true;
        food[ind] = m + 1;
        m ^= 1;
        if (m) {
          if (ind & 1)
            ++ind;
          else
            --ind;
        } else
          ind = p[ind];
      }
    }
  for (int i = 1; i <= n; ++i)
    printf("%d %d\n", food[v[i].first], food[v[i].second]);
  return 0;
}
