#include <bits/stdc++.h>
using namespace std;
inline int read() {
  char c = getchar();
  int x = 0;
  bool f = 0;
  for (; !isdigit(c); c = getchar()) f ^= !(c ^ 45);
  for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
  if (f) x = -x;
  return x;
}
int n, col[300005], vis[300005], x[300005], y[300005];
vector<int> e[300005];
void dfs(int u, int d) {
  col[u] = d, vis[u] = 1;
  for (auto v : e[u])
    if (!vis[v]) dfs(v, !d);
}
signed main() {
  n = read();
  for (register int i = (1); i <= (n); ++i) {
    int u = read(), v = read();
    e[u].push_back(v), e[v].push_back(u);
    x[i] = u, y[i] = v;
  }
  for (register int i = (1); i <= (n); ++i) {
    e[i * 2 - 1].push_back(i << 1);
    e[i << 1].push_back(i * 2 - 1);
  }
  for (register int i = (1); i <= (n * 2); ++i)
    if (!vis[i]) dfs(i, 0);
  for (register int i = (1); i <= (n); ++i)
    printf("%d %d\n", col[x[i]] + 1, col[y[i]] + 1);
  return 0;
}
