#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const int N = 2e5 + 10;
int n, p[N], x[N], y[N];
vector<int> eg[N];
bool dfs(int u) {
  for (int i = 0; i < eg[u].size(); i++) {
    int v = eg[u][i];
    if (!p[v]) {
      p[v] = p[u] == 1 ? 2 : 1;
      dfs(v);
    } else if (p[v] == p[u])
      return 0;
  }
  return 1;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &x[i], &y[i]);
    eg[x[i]].push_back(y[i]);
    eg[y[i]].push_back(x[i]);
  }
  for (int i = 1; i < 2 * n; i += 2)
    eg[i].push_back(i + 1), eg[i + 1].push_back(i);
  p[1] = 1;
  bool flag = 1;
  for (int i = 1; i <= n * 2; i++)
    if (p[i]) {
      flag = dfs(i);
      if (!flag) break;
    } else {
      p[i] = 1;
      flag = dfs(i);
      if (!flag) break;
    }
  if (!flag)
    printf("-1\n");
  else {
    for (int i = 1; i <= n; i++) printf("%d %d\n", p[x[i]], p[y[i]]);
  }
  return 0;
}
