#include <bits/stdc++.h>
using namespace std;
const int M = 200005;
int c[M], n;
vector<pair<int, int> > v;
vector<int> g[M];
void dfs(int u) {
  for (int i = 0; i < g[u].size(); i++) {
    int v = g[u][i];
    if (c[v]) continue;
    c[v] = 3 - c[u];
    dfs(v);
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    a--, b--;
    g[a].push_back(b);
    g[b].push_back(a);
    v.push_back(make_pair(a, b));
  }
  for (int i = 0; i < 2 * n; i++) {
    int j = (i + 1) % (2 * n);
    g[i].push_back(j);
    g[j].push_back(i++);
  }
  for (int i = 0; i < 2 * n; i++)
    if (!c[i]) c[i] = 1, dfs(i);
  for (int i = 0; i < v.size(); i++)
    printf("%d %d\n", c[v[i].first], c[v[i].second]);
  return 0;
}
