#include <bits/stdc++.h>
using namespace std;
const int nn = 200200;
vector<int> e[nn];
pair<int, int> pr[nn];
int val[nn], vis[nn];
void dfs(int x, int v) {
  val[x] = v;
  vis[x] = 1;
  for (auto c : e[x])
    if (!vis[c]) dfs(c, v ^ 1);
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    pr[i] = make_pair(x, y);
    e[x].push_back(y);
    e[y].push_back(x);
  }
  for (int i = 1; i <= n; i++) {
    e[i * 2].push_back(2 * i - 1);
    e[2 * i - 1].push_back(2 * i);
  }
  for (int i = 1; i < 2 * n + 1; i++)
    if (!vis[i]) dfs(i, 0);
  for (int i = 0; i < n; i++)
    printf("%d %d\n", val[pr[i].first] + 1, val[pr[i].second] + 1);
  return 0;
}
