#include <bits/stdc++.h>
using namespace std;
struct point {
  point *next;
  int to;
} * head[100050 << 1];
int a[100050], b[100050], v[100050 << 1];
void dfs(int, int);
inline void link(int, int), read(int &);
int main() {
  int n;
  read(n);
  for (int i(1); i <= n; ++i)
    read(a[i]), read(b[i]), link(a[i], b[i]), link(b[i], a[i]);
  for (int i(1); i <= n; ++i) link(2 * i - 1, 2 * i), link(2 * i, 2 * i - 1);
  for (int i(1); i <= n << 1; ++i)
    if (!v[i]) dfs(i, 1);
  for (int i(1); i <= n; ++i) printf("%d %d\n", v[a[i]], v[b[i]]);
  return 0;
}
void dfs(int x, int color) {
  v[x] = color;
  for (point *i(head[x]); i != NULL; i = i->next)
    if (!v[i->to]) dfs(i->to, 3 - color);
}
inline void read(int &x) {
  x ^= x;
  register char c;
  while (c = getchar(), c < '0' || c > '9')
    ;
  while (c >= '0' && c <= '9')
    x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
}
inline void link(int u, int v) { head[u] = new point{head[u], v}; }
