#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > G((int)2e5 + 11);
vector<int> used((int)2e5 + 11, 0);
bool flag = false;
void dfs(int u, int cl = 1) {
  if (!used[u]) {
    used[u] = cl;
  }
  for (int i = 0; i < G[u].size(); ++i) {
    if (!used[G[u][i]])
      dfs(G[u][i], 3 - cl);
    else if (used[G[u][i]] == used[u]) {
      used[G[u][i]] = 1000010000;
      cout << -1 << endl;
      exit(0);
    }
  }
}
vector<int> a((int)2e5 + 11, 0);
vector<int> b((int)2e5 + 11, 0);
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.precision(0);
  int n, t;
  cin >> n;
  for (int kk = 0; kk < n; ++kk) {
    int u, v;
    cin >> u >> v;
    a[kk] = u;
    b[kk] = v;
    G[u].push_back(v);
    G[v].push_back(u);
  }
  for (int i = 1; i <= n; ++i) {
    G[2 * i].push_back((2 * i + 1) % (2 * n + 2));
    G[(2 * i + 1) % (2 * n + 2)].push_back(2 * i);
  }
  for (int i = 1; i <= 2 * n; ++i) {
    if (!used[i]) dfs(i);
  }
  for (int i = 0; i < n; ++i) {
    cout << used[a[i]] << " " << used[b[i]] << endl;
  }
  return 0;
}
