#include <bits/stdc++.h>
using namespace std;
const int N = 101010 << 1;
int a[N], b[N], n, vis[N], col[N];
vector<int> g[N];
void link(int a, int b) {
  g[a].push_back(b);
  g[b].push_back(a);
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < (n); ++i) {
    scanf("%d%d", a + i, b + i);
    a[i]--, b[i]--;
    link(a[i], b[i]);
  }
  for (int i = 0; i < (n); ++i) link(i << 1, i << 1 | 1);
  for (int i = 0; i < (n + n); ++i)
    if (!vis[i]) {
      vector<int> v;
      int c = i;
      while (!vis[c]) {
        v.push_back(c);
        vis[c] = true;
        int u = 0;
        for (auto e : g[c])
          if (!vis[e]) {
            u = e;
            break;
          }
        c = u;
      }
      for (int i = 0; i < ((int)(v).size()); ++i) col[v[i]] = i & 1;
    }
  for (int i = 0; i < (n); ++i) printf("%d %d\n", col[a[i]] + 1, col[b[i]] + 1);
  return 0;
}
