#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int n, vis[maxn * 2], lab[maxn * 2];
vector<int> v[2 * maxn];
pair<int, int> pp[maxn];
void dfs(int x, int y) {
  if (vis[x]) return;
  vis[x] = 1;
  lab[x] = y;
  for (auto it : v[x])
    if (!vis[it]) dfs(it, y ^ 1);
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    v[2 * i].push_back(2 * i - 1);
    v[2 * i - 1].push_back(2 * i);
    int x, y;
    cin >> x >> y;
    pp[i] = pair<int, int>(x, y);
    v[x].push_back(y);
    v[y].push_back(x);
  }
  for (int i = 1; i <= 2 * n; i++)
    if (!vis[i]) dfs(i, 0);
  for (int i = 1; i <= n; i++)
    printf("%d %d\n", lab[pp[i].first] + 1, lab[pp[i].second] + 1);
  return 0;
}
