#include <bits/stdc++.h>
const int MAX_N = (int)5e5 + 5;
const int inf = (int)1e9 + 123;
using namespace std;
int n;
vector<int> g[MAX_N];
pair<int, int> a[MAX_N];
int u[MAX_N];
void dfs(int v, int cl = 1) {
  if (u[v]) {
    assert(u[v] == cl);
    return;
  }
  u[v] = cl;
  for (auto to : g[v]) dfs(to, (cl == 1 ? 2 : 1));
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i].first >> a[i].second;
    g[a[i].first].push_back(a[i].second);
    g[a[i].second].push_back(a[i].first);
  }
  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 (!u[i]) dfs(i);
  for (int i = 1; i <= n; i++)
    cout << u[a[i].first] << ' ' << u[a[i].second] << '\n';
  return 0;
}
