#include <bits/stdc++.h>
using namespace std;
vector<long long> v[210000];
int color[210000];
bool flag = true;
void dfs(long long s, long long c) {
  if (!flag) return;
  color[s] = c;
  for (long long i = 0; i < v[s].size(); i++) {
    if (color[v[s][i]] != 0) {
      if (color[v[s][i]] == color[s]) {
        flag = false;
        return;
      }
    } else {
      if (c == 1) {
        dfs(v[s][i], 2);
      } else {
        dfs(v[s][i], 1);
      }
    }
  }
}
int main() {
  long long n;
  scanf("%lld", &n);
  pair<long long, long long> a[n + 10];
  memset(color, 0, sizeof color);
  for (long long i = 1; i <= n; i++) {
    scanf("%lld", &a[i].first), scanf("%lld", &a[i].second);
    v[a[i].first].push_back(a[i].second);
    v[a[i].second].push_back(a[i].first);
  }
  for (int i = 1; i <= 2 * n; i += 2) {
    v[i].push_back(i + 1);
    v[i + 1].push_back(i);
  }
  for (long long i = 1; i <= 2 * n; i++) {
    if (color[i] != 0) continue;
    dfs(i, 1);
    if (!flag) {
      printf("-1\n");
    }
  }
  for (long long i = 1; i <= n; i++) {
    printf("%d %d\n", color[a[i].first], color[a[i].second]);
  }
}
