#include <bits/stdc++.h>
const int N = 3e5;
int a[N], b[N], c[N], d[N], n;
void e(int u, int y) {
  d[u ^ 1] = 3 - (d[u] = y);
  if (!d[c[u]]) e(c[u], 3 - y);
  if (!d[c[u ^ 1]]) e(c[u ^ 1], y);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++)
    scanf("%d%d", a + i, b + i), a[i]--, b[i]--, c[a[i]] = b[i], c[b[i]] = a[i];
  for (int i = 0; i < n + n; i += 2)
    if (!d[i]) e(i, 1);
  for (int i = 1; i <= n; i++) printf("%d %d\n", d[a[i]], d[b[i]]);
}
