#include <bits/stdc++.h>
using namespace std;
int n;
int a[100010];
int b[100010];
int color[200010];
vector<int> G[200010];
bool visited[200010];
void dfs(int idx, int col) {
  visited[idx] = true;
  color[idx] = col;
  for (auto i : G[idx])
    if (!visited[i]) dfs(i, col ^ 1);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &a[i], &b[i]);
    G[a[i]].push_back(b[i]);
    G[b[i]].push_back(a[i]);
  }
  for (int i = 1; i <= n; i++) {
    G[2 * i].push_back(2 * i - 1);
    G[2 * i - 1].push_back(2 * i);
  }
  for (int i = 1; i <= 2 * n; i++)
    if (!visited[i]) dfs(i, 0);
  for (int i = 1; i <= n; i++)
    printf("%d %d\n", color[a[i]] + 1, color[b[i]] + 1);
  return 0;
}
