#include <bits/stdc++.h>
using namespace std;
template <typename T>
T qmin(const T a, const T b) {
  return a < b ? a : b;
}
template <typename T>
T qmax(const T a, const T b) {
  return a > b ? a : b;
}
template <typename T>
void getmin(T &a, const T b) {
  if (a > b) a = b;
}
template <typename T>
void getmax(T &a, const T b) {
  if (a < b) a = b;
}
void fileio(string s) {
  if (s.empty()) return;
  freopen((s + ".in").c_str(), "r", stdin);
  freopen((s + ".out").c_str(), "w", stdout);
}
const int inf = 1e9 + 7;
const long long linf = 1e17 + 7;
const int N = 4e5 + 7;
int match[N], a[N], b[N], col[N], n;
void dfs(int u) {
  if (!col[u ^ 1]) {
    col[u ^ 1] = 3 - col[u];
    dfs(u ^ 1);
  }
  if (!col[match[u]]) {
    col[match[u]] = 3 - col[u];
    dfs(match[u]);
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d%d", a + i, b + i);
    --a[i], --b[i];
    match[a[i]] = b[i], match[b[i]] = a[i];
  }
  for (int i = 0; i < n << 1; ++i) {
    if (col[i]) continue;
    col[i] = 1;
    dfs(i);
  }
  for (int i = 1; i <= n; ++i) {
    printf("%d %d\n", col[a[i]], col[b[i]]);
  }
  return 0;
}
