#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 7;
vector<int> G[N];
pair<int, int> p[N];
int t[N];
bool ok = 1;
void dfs(int v) {
  if (!ok) return;
  for (int i = 0; i < G[v].size(); i++) {
    if (t[v] == t[G[v][i]]) {
      ok = 0;
      return;
    }
    if (!t[G[v][i]]) {
      t[G[v][i]] = 1 + ((t[v] - 1) ^ 1);
      dfs(G[v][i]);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, a, b;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a >> b;
    G[a].push_back(b);
    G[b].push_back(a);
    p[i] = make_pair(a, b);
  }
  for (int i = 1; i < n << 1; i += 2) {
    G[i].push_back(i + 1);
    G[i + 1].push_back(i);
  }
  for (int i = 1; i <= n << 1; i++) {
    if (!t[i]) {
      t[i] = 1;
      dfs(i);
    }
  }
  if (!ok)
    cout << -1;
  else {
    for (int i = 0; i < n; i++) {
      cout << t[p[i].first] << ' ' << t[p[i].second] << '\n';
    }
  }
  return 0;
}
