#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int n, v, u, c[N], visit[N];
vector<int> g[N];
pair<int, int> a[N / 2];
void dfs(int ver, int cl) {
  c[ver] = cl + 1;
  visit[ver] = 1;
  for (int i = 0; i < ((int)g[ver].size()); ++i) {
    v = g[ver][i];
    if (!visit[v]) dfs(v, 1 - cl);
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> u >> v;
    a[i] = pair<int, int>(u, v);
    g[u].push_back(v), g[v].push_back(u);
  }
  for (int i = 0; i < n; ++i) {
    u = (i << 1) + 1;
    v = (i << 1) + 2;
    g[u].push_back(v), g[v].push_back(u);
  }
  for (int i = 1; i < 2 * n + 1; ++i)
    if (!visit[i]) dfs(i, 0);
  for (int i = 0; i < n; ++i) printf("%d %d\n", c[a[i].first], c[a[i].second]);
  return 0;
}
