#include <bits/stdc++.h>
using namespace std;
const int M = 1000010;
const int N = 10010;
int n, a[211111], b[211111], col[211111];
vector<int> ve[211111];
bool dfs(int u) {
  for (int i = 0; i < ve[u].size(); i++) {
    int v = ve[u][i];
    if (col[u] == col[v]) return false;
    if (!col[v]) {
      col[v] = 3 - col[u];
      if (!dfs(v)) return false;
    }
  }
  return true;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", a + i, b + i);
    ve[a[i]].push_back(b[i]);
    ve[b[i]].push_back(a[i]);
  }
  for (int i = 1; i <= n; i++) {
    ve[2 * i].push_back(2 * i - 1);
    ve[2 * i - 1].push_back(2 * i);
  }
  for (int i = 1; i <= 2 * n; i++)
    if (!col[i]) {
      col[i] = 1;
      dfs(i);
    }
  for (int i = 1; i <= n; i++) printf("%d %d\n", col[a[i]], col[b[i]]);
  return 0;
}
