#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int sum = 0, ff = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') ff = -1;
    ch = getchar();
  }
  while (isdigit(ch)) sum = sum * 10 + (ch ^ 48), ch = getchar();
  return sum;
}
const int N = 2e5 + 5;
int n, m, col[N], ux[N], uy[N], vis[N];
vector<int> G[N];
inline void dfs(int u, int op) {
  col[u] = op;
  vis[u] = 1;
  for (int i = 0; i < G[u].size(); i++) {
    int v = G[u][i];
    if (!col[v]) dfs(v, op ^ 1);
  }
}
int main() {
  n = read();
  for (int i = 1; i <= n; i++) {
    int x, y;
    x = read();
    y = read();
    G[x].push_back(y);
    G[y].push_back(x);
    ux[i] = x, uy[i] = y;
  }
  m = n << 1;
  for (int i = 1; i <= n; i++)
    G[i * 2 - 1].push_back(i << 1), G[i << 1].push_back(i * 2 - 1);
  for (int i = 1; i <= m; i++)
    if (!vis[i]) dfs(i, 1);
  for (int i = 1; i <= n; i++)
    printf("%d %d\n", col[ux[i]] + 1, col[uy[i]] + 1);
  return 0;
}
