#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int n;
struct relationship {
  int a;
  int b;
} r[N];
vector<int> nb[2 * N];
bool vis[2 * N];
bool odd_cycle = false;
int in_time[2 * N];
void DFS(int v, int parent, int clock) {
  vis[v] = true;
  in_time[v] = clock++;
  for (int i = 0; i < nb[v].size(); i++) {
    if (nb[v][i] == parent) continue;
    if (vis[nb[v][i]]) {
      if ((in_time[v] - in_time[nb[v][i]]) % 2 == 1) {
        odd_cycle = true;
        cerr << nb[v][i] << " " << v << " " << parent << endl;
      }
    } else {
      DFS(nb[v][i], v, in_time[v]);
    }
  }
}
int color[2 * N];
void Coloring(int v, int col) {
  vis[v] = true;
  color[v] = col;
  if (col == 1)
    col = 2;
  else
    col = 1;
  for (int i = 0; i < nb[v].size(); i++) {
    if (!vis[nb[v][i]]) {
      Coloring(nb[v][i], col);
    }
  }
}
int main() {
  int i;
  cin >> n;
  for (i = 1; i <= n; i++) {
    scanf("%d%d", &r[i].a, &r[i].b);
    nb[r[i].a].push_back(r[i].b);
    nb[r[i].b].push_back(r[i].a);
  }
  for (i = 1; i < n; i++) {
    nb[2 * i].push_back(2 * i + 1);
    nb[2 * i + 1].push_back(2 * i);
  }
  nb[2 * n].push_back(1);
  nb[1].push_back(2 * n);
  for (i = 1; i <= 2 * n; i++) {
    if (!vis[i]) {
      DFS(i, -1, 1);
    }
  }
  if (odd_cycle) {
    printf("-1\n");
    return 0;
  }
  memset(vis, false, sizeof(vis));
  for (i = 1; i <= 2 * n; i++) {
    if (!vis[i]) {
      Coloring(i, 1);
    }
  }
  for (i = 1; i <= n; i++) {
    printf("%d %d\n", color[r[i].a], color[r[i].b]);
  }
  return 0;
}
