#include <bits/stdc++.h>
using namespace std;
const int mxn = 1e5 + 3;
vector<pair<int, int> > g;
int ans[mxn * 2], n;
map<int, int> mat;
int main() {
  scanf("%d", &n);
  for (int(i) = (int)(0); (i) < (int)(n); ++(i)) {
    int u, v;
    scanf("%d%d", &u, &v);
    g.push_back(make_pair(u, v));
    mat[u] = v;
    mat[v] = u;
  }
  for (int(i) = (int)(1); (i) <= (int)(2 * n); ++(i))
    if (!ans[i]) {
      int cur = i;
      while (ans[cur] == 0) {
        ans[cur] = 1;
        int nxt;
        if (cur & 1)
          nxt = cur + 1;
        else
          nxt = cur - 1;
        if (ans[nxt] == 0) {
          ans[nxt] = 2;
          cur = mat[nxt];
        }
      }
    }
  for (int(i) = (int)(0); (i) < (int)(n); ++(i))
    printf("%d %d\n", ans[g[i].first], ans[g[i].second]);
  return 0;
}
