#include <bits/stdc++.h>
using namespace std;
vector<int> G[200005];
bool vis[200005];
int c[200005], n, A[200005], B[200005];
void add_e(int a, int b) { G[a].push_back(b); }
void dfs(int x, int t) {
  c[x] = t;
  vis[x] = true;
  vector<int>::iterator it;
  for (it = G[x].begin(); it != G[x].end(); it++)
    if (!vis[*it]) dfs(*it, t ^ 1);
  ;
}
int main() {
  int a, b;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &a, &b);
    A[i] = a;
    B[i] = b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  for (int i = 1; i <= n; i++) {
    G[i * 2].push_back(i * 2 - 1);
    G[i * 2 - 1].push_back(i * 2);
  }
  for (int i = 1; i <= n * 2; i++)
    if (!vis[i]) dfs(i, 0);
  for (int i = 1; i <= n; i++) printf("%d %d\n", c[A[i]] + 1, c[B[i]] + 1);
  return 0;
}
