#include <bits/stdc++.h>
using namespace std;
int n;
struct edge {
  int v, next, w;
  edge() {}
  edge(int v, int next, int w) {
    this->v = v;
    this->next = next;
    this->w = w;
  }
} ed[1005000 * 2];
int ptx[1005000], lnum;
void addline(int x, int y, int w) {
  ed[lnum] = edge(y, ptx[x], w);
  ptx[x] = lnum++;
}
int a[1005000];
int b[1005000];
int mark[1005000];
int ok = 1;
void init() {
  memset(ptx, -1, sizeof(ptx));
  lnum = 0;
  memset(mark, 0, sizeof(mark));
}
void dfs(int now, int flag) {
  mark[now] = flag;
  for (int i = ptx[now]; ~i; i = ed[i].next) {
    int v = ed[i].v;
    if (mark[v] == 0) {
      dfs(v, 3 - flag);
    }
  }
}
int main(void) {
  scanf("%d", &n);
  init();
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &a[i], &b[i]);
    addline(a[i], b[i], 0);
    addline(b[i], a[i], 0);
    addline(2 * (i + 1), 2 * i + 1, 0);
    addline(2 * i + 1, 2 * (i + 1), 0);
  }
  for (int i = 1; i <= 2 * n; i++) {
    if (mark[i] == 0) dfs(i, 1);
  }
  if (ok == 0) {
    printf("-1\n");
  } else {
    for (int i = 0; i < n; i++) {
      printf("%d %d\n", mark[a[i]], mark[b[i]]);
    }
  }
  return 0;
}
