#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 5;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
vector<int> ss[maxn];
int n;
int col[maxn];
bool dfs(int u, int cc) {
  col[u] = cc;
  for (int i = 0; i < ss[u].size(); i++) {
    int v = ss[u][i];
    if (col[v] == -1) {
      return dfs(v, cc == 1 ? 2 : 1);
    } else if (col[v] == col[u])
      return false;
  }
  return true;
}
pair<int, int> s1[maxn];
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int u, v;
    cin >> u >> v;
    ss[u].push_back(v);
    ss[v].push_back(u);
    s1[i] = make_pair(u, v);
  }
  for (int i = 1; i <= 2 * n; i += 2) {
    ss[i].push_back(i + 1);
    ss[i + 1].push_back(i);
  }
  memset(col, -1, sizeof(col));
  for (int i = 1; i <= 2 * n; i++) {
    if (col[i] == -1) {
      int flag = dfs(i, 1);
      if (flag == 0) {
        cout << "-1" << endl;
        return 0;
      }
    }
  }
  for (int i = 1; i <= n; i++)
    cout << col[s1[i].first] << ' ' << col[s1[i].second] << endl;
  return 0;
}
