#include <bits/stdc++.h>
using namespace std;
const int INF = 1e7;
const int MOD = 1e9 + 7;
int n, color[200005], a[100005], b[100005];
vector<vector<int> > adjlist;
void dfs(int u, int prv) {
  color[u] = (prv) ? 0 : 1;
  for (int i = 0; i < ((int)(adjlist[u]).size()); i++) {
    int v = adjlist[u][i];
    if (color[v] == -1) dfs(v, (prv + 1) % 2);
  }
}
int main() {
  scanf("%d", &n);
  adjlist.assign(2 * n, vector<int>());
  for (int i = 0; i < n; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    u--;
    v--;
    a[i] = u;
    b[i] = v;
    adjlist[u].push_back(v);
    adjlist[v].push_back(u);
  }
  n *= 2;
  for (int i = 1; i < n; i += 2) {
    adjlist[i].push_back(i - 1);
    adjlist[i - 1].push_back(i);
  }
  memset((color), (-1), sizeof(color));
  for (int i = 0; i < n; i++)
    if (color[i] == -1) dfs(i, 1);
  bool ok = 1;
  for (int u = 0; u < n; u++) {
    for (int i = 0; i < ((int)(adjlist[u]).size()); i++) {
      int v = adjlist[u][i];
      if (color[u] == color[v]) ok = 0;
    }
  }
  if (!ok) return 0 * puts("-1");
  for (int i = 0; i < n / 2; i++)
    printf("%d %d\n", color[a[i]] + 1, color[b[i]] + 1);
  return 0;
}
