#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:102400000,102400000")
const int maxn = 2e5 + 5;
pair<int, int> f[maxn];
vector<int> G[maxn];
int n;
int ty[maxn], vis[maxn];
void dfs(int pos, int val) {
  vis[pos] = true;
  ty[pos] = val;
  for (int i = 0; i < G[pos].size(); i++) {
    int v = G[pos][i];
    if (vis[v]) continue;
    dfs(v, val ^ 1);
  }
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    f[i] = make_pair(u, v);
    G[u].push_back(v), G[v].push_back(u);
  }
  for (int i = 1; i <= n; i++) {
    G[2 * i].push_back(2 * i - 1), G[2 * i - 1].push_back(2 * i);
  }
  for (int i = 1; i <= n * 2; i++) {
    if (!vis[i]) dfs(i, 1);
  }
  for (int i = 1; i <= n; i++) {
    int u = f[i].first, v = f[i].second;
    printf("%d %d\n", ty[u] + 1, ty[v] + 1);
  }
  return 0;
}
