#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const long long int INFF = 1e17;
const double EPS = 1e-9;
const long long int MOD = 1e9 + 7;
const int N = 2e5 + 10;
vector<vector<int> > g(N);
vector<pair<int, int> > e;
int n, ans[N];
bool bfs() {
  bool vis[N];
  queue<int> q;
  q.push(0);
  for (int i = (0); i < (2 * n); ++i) ans[i] = -1;
  for (int i = (0); i < (2 * n); ++i) vis[i] = 0;
  ans[0] = 0;
  int start = 1;
  while (!q.empty()) {
    int v = q.front();
    q.pop();
    for (auto u : g[v]) {
      if (ans[u] != -1 && ans[u] == ans[v]) return 0;
      ans[u] = !(ans[v]);
      if (!vis[u]) q.push(u), vis[u] = 1;
    }
    if (q.empty()) {
      for (int i = (start); i < (2 * n); ++i)
        if (!vis[i]) {
          ans[i] = 0, q.push(i);
          start = i + 1;
          break;
        }
    }
  }
  return 1;
}
int main() {
  scanf("%d", &n);
  for (int i = (0); i < (n); ++i) {
    int t1, t2;
    scanf("%d %d", &t1, &t2);
    t1--, t2--;
    g[t1].push_back(t2), g[t2].push_back(t1);
    e.push_back({t1, t2});
  }
  for (int i = (0); i < (n); ++i)
    g[2 * i].push_back(2 * i + 1), g[2 * i + 1].push_back(2 * i);
  if (bfs()) {
    for (auto u : e) printf("%d %d\n", ans[u.first] + 1, ans[u.second] + 1);
  } else
    puts("-1");
  return 0;
}
