#include <bits/stdc++.h>
using namespace std;
const int MAXN = (int)2e5 + 22;
const long long INF = (long long)1e9 + 47;
int to[MAXN];
int N;
bool used[MAXN];
int boy[MAXN], girl[MAXN];
int cc[MAXN];
void go(int v, int color = 0) {
  used[v] = 1;
  cc[v] = color;
  int u = to[v];
  if (!used[u])
    go(u, color ^ 1);
  else if (!used[v ^ 1])
    go(v ^ 1, color ^ 1);
}
void solve() {
  cin >> N;
  for (int i = 0; i < N; i++) {
    int x, y;
    cin >> x >> y;
    --x, --y;
    to[x] = y;
    to[y] = x;
    boy[i] = x;
    girl[i] = y;
  }
  for (int i = 0; i < 2 * N; i++) {
    if (!used[i]) go(i, cc[(i - 1 + N) % N] ^ 1);
  }
  for (int i = 0; i < N; i++)
    cout << cc[boy[i]] + 1 << " " << cc[girl[i]] + 1 << "\n";
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  solve();
  return 0;
}
