#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
int n, a[maxn], b[maxn], ans[maxn];
vector<int> g[maxn];
bool visited[maxn];
void dfs(int i, int status) {
  visited[i] = 1;
  ans[i] = status % 2 + 1;
  for (int x : g[i]) {
    if (!visited[x]) {
      dfs(x, status + 1);
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
    g[a[i]].push_back(b[i]);
    g[b[i]].push_back(a[i]);
  }
  for (int i = 1; i < 2 * n; i += 2) {
    g[i].push_back(i + 1);
    g[i + 1].push_back(i);
  }
  for (int i = 1; i <= 2 * n; i++) {
    if (!visited[i]) {
      dfs(i, 0);
    }
  }
  for (int i = 0; i < n; i++) {
    cout << ans[a[i]] << ' ' << ans[b[i]] << '\n';
  }
  return 0;
}
