#include <bits/stdc++.h>
using namespace std;
vector<int> mp[1234567];
int b[1234567], x[1234567], y[1234567];
int flag = 0;
void dfs(int u, int num) {
  b[u] = num;
  for (int i = 0; i < mp[u].size(); i++) {
    int v = mp[u][i];
    if (b[v] == 0) {
      dfs(v, 3 - num);
    }
  }
}
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> x[i] >> y[i];
    mp[x[i]].push_back(y[i]);
    mp[y[i]].push_back(x[i]);
    mp[2 * i].push_back(2 * i - 1);
    mp[2 * i - 1].push_back(2 * i);
  }
  for (int i = 1; i <= 2 * n; i++)
    if (b[i] == 0) dfs(i, 1);
  if (flag)
    cout << -1;
  else {
    for (int i = 1; i <= n; i++) printf("%d %d\n", b[x[i]], b[y[i]]);
  }
  return 0;
}
