#include <bits/stdc++.h>
using namespace std;
int n, a, b;
vector<pair<int, int> > res;
vector<vector<int> > v;
int cl[100000 * 2 + 5];
bool visited[100000 * 2 + 5];
void dfs(int now, int color) {
  if (visited[now]) return;
  visited[now] = true;
  cl[now] = color + 1;
  for (int i = 0; i < v[now].size(); i++) {
    dfs(v[now][i], !color);
  }
}
int main() {
  scanf("%d", &n);
  v.resize(n * 2);
  for (int i = 0; i < n; i++) {
    scanf("%d %d", &a, &b);
    a--;
    b--;
    res.push_back(make_pair(a, b));
    v[a].push_back(b);
    v[b].push_back(a);
  }
  for (int i = 0; i < 2 * n; i += 2) {
    v[i].push_back((i + 1) % (n * 2));
    v[(i + 1) % (n * 2)].push_back(i);
  }
  for (int i = 0; i < 2 * n; i++) {
    if (!visited[i]) {
      dfs(i, 0);
    }
  }
  for (int i = 0; i < n; i++) {
    printf("%d %d\n", cl[res[i].first], cl[res[i].second]);
  }
}
