#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3fffffff;
const int SINF = 0x7fffffff;
const long long LINF = 0x3fffffffffffffff;
const long long SLINF = 0x7fffffffffffffff;
const int MAXN = 200007;
int n;
int pr[MAXN];
int ans[MAXN];
int id[MAXN][2];
bool vis[MAXN];
void init();
void input();
void work();
int main() {
  init();
  input();
  work();
}
void init() { ios::sync_with_stdio(false); }
void input() {
  scanf("%d", &n);
  int u, v;
  for (int i = 0; i < n; ++i) {
    scanf("%d%d", &u, &v);
    --u, --v;
    pr[u] = v, pr[v] = u;
    id[i][0] = u, id[i][1] = v;
  }
}
void work() {
  memset(vis, false, sizeof(vis));
  int ns = n << 1;
  int now;
  for (int i = 0; i < ns; ++i) {
    if (!vis[i]) {
      now = i;
      while (!vis[now]) {
        ans[now] = 1;
        vis[now] = true;
        now = pr[now];
        ans[now] = 2;
        vis[now] = true;
        now ^= 1;
      }
    }
  }
  for (int i = 0; i < n; ++i) printf("%d %d\n", ans[id[i][0]], ans[id[i][1]]);
}
