#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
struct node {
  int to, next;
} a[N << 4];
int n, cnt, hand[N], lx[N], ly[N], co[N], fl;
void add(int x, int y) {
  a[++cnt].to = y;
  a[cnt].next = hand[x];
  hand[x] = cnt;
}
void dfs(int x) {
  if (fl) return;
  for (int i = hand[x]; i; i = a[i].next) {
    if (co[a[i].to] == co[x]) {
      fl = 1;
      return;
    }
    if (!co[a[i].to]) co[a[i].to] = co[x] ^ 3, dfs(a[i].to);
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &lx[i], &ly[i]);
    add(lx[i], ly[i]);
    add(ly[i], lx[i]);
    add(i * 2 - 1, i * 2);
    add(i * 2, i * 2 - 1);
  }
  for (int i = 1; i <= n * 2; ++i)
    if (!co[i]) co[i] = 1, dfs(i);
  dfs(1);
  if (!fl)
    for (int i = 1; i <= n; i++) cout << co[lx[i]] << " " << co[ly[i]] << endl;
  else
    cout << -1 << endl;
}
