#include <bits/stdc++.h>
const long long int mrx = 1e6 + 5, M = 1e9 + 7;
long long int mx = INT_MIN, mn = INT_MAX;
using namespace std;
long long int a[mrx], b[mrx], d, color[mrx], used[mrx];
vector<long long int> s[mrx];
map<pair<long long int, long long int>, long long int> m;
void dfs(long long int v, long long int cnt) {
  used[v] = 1;
  color[v] = cnt;
  for (int i = 0; i < s[v].size(); i++) {
    if (used[s[v][i]] == 0) {
      if (cnt == 1)
        dfs(s[v][i], 2);
      else
        dfs(s[v][i], 1);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(NULL);
  cin.tie(NULL);
  cin >> d;
  for (int i = 1; i <= d; i++) {
    cin >> a[i] >> b[i];
    if (m[make_pair(a[i], b[i])] == 0) {
      m[make_pair(a[i], b[i])] = 1;
      s[a[i]].push_back(b[i]);
    }
    if (m[make_pair(b[i], a[i])] == 0) {
      m[make_pair(b[i], a[i])] = 1;
      s[b[i]].push_back(a[i]);
    }
    if (m[make_pair(2 * i - 1, 2 * i)] == 0) {
      m[make_pair(2 * i - 1, 2 * i)] = 1;
      s[i * 2 - 1].push_back(i * 2);
    }
    if (m[make_pair(2 * i, 2 * i - 1)] == 0) {
      m[make_pair(2 * i, 2 * i - 1)] = 1;
      s[i * 2].push_back(i * 2 - 1);
    }
  }
  for (int i = 1; i <= d * 2; i++) {
    if (!used[i]) {
      dfs(i, 1);
    }
  }
  for (int i = 1; i <= d; i++) {
    cout << color[a[i]] << " " << color[b[i]] << "\n";
  }
  return 0;
}
