#include <bits/stdc++.h>
using namespace std;
template <class T>
void rd(T &x) {
  static char c;
  static int f;
  x = 0;
  f = 1;
  while (c = getchar(), c < 48)
    if (c == '-') f = -1;
  do x = (x * 10) + (c & 15);
  while (c = getchar(), c > 47);
  x *= f;
}
template <class T>
void prin(T x) {
  if (x < 0)
    x = -x, putchar('-');
  else if (!x) {
    putchar('0');
    return;
  }
  static int tp, stk[100];
  while (x) stk[tp++] = x % 10, x /= 10;
  while (tp) putchar(stk[--tp] ^ 48);
}
template <class T>
void ptn(T x) {
  prin(x);
  putchar('\n');
}
template <class T>
void ptk(T x) {
  prin(x);
  putchar(' ');
}
template <class T>
void Min(T &a, T b) {
  if (a > b) a = b;
}
template <class T>
void Max(T &a, T b) {
  if (a < b) a = b;
}
const int N = (int)2e5 + 5;
int ch[2][N], n, co[N];
pair<int, int> pos[N];
void dfs(int x, bool f) {
  co[x] = f;
  for (int i = 0; i < 2; ++i)
    if (!~co[ch[i][x]]) dfs(ch[i][x], !f);
}
void solve() {
  memset(co, -1, sizeof co);
  rd(n);
  for (int x, y, i = 0; i < n; ++i) {
    rd(x), rd(y);
    pos[i] = pair<int, int>(x, y);
    ch[0][x] = y;
    ch[0][y] = x;
  }
  for (int i = (1), _t = (n + 1); i < _t; ++i)
    ch[1][i * 2 - 1] = i * 2, ch[1][i * 2] = i * 2 - 1;
  for (int i = (1), _t = (n << 1 | 1); i < _t; ++i)
    if (!~co[i]) dfs(i, 0);
  for (int i = (0), _t = (n); i < _t; ++i)
    ptk(co[pos[i].first] + 1), ptn(co[pos[i].second] + 1);
}
int main() {
  int T = 1;
  while (T--) solve();
  return 0;
}
