#include <bits/stdc++.h>
using namespace std;
const int dir[8][2] = {0, 1, 0, -1, 1, 0, -1, 0, 1, 1, 1, -1, -1, 1, -1, -1};
const int INF = 0x3f3f3f3f;
const int N = 1e5 + 10;
const long long mod = 998244353;
int n;
pair<int, int> a[N];
int col[N * 2];
vector<int> adj[N * 2];
void dfs(int x, int c) {
  if (col[x] != 0) return;
  col[x] = c;
  for (int v : adj[x]) dfs(v, c == 1 ? 2 : 1);
}
void sol() {
  scanf("%d", &n);
  for (int i = (0); i < (n); ++i) {
    scanf("%d%d", &a[i].first, &a[i].second);
    adj[a[i].first].push_back(a[i].second);
    adj[a[i].second].push_back(a[i].first);
    adj[2 * i + 1].push_back(2 * i + 2);
    adj[2 * i + 2].push_back(2 * i + 1);
  }
  for (int i = (1); i <= (n * 2); ++i)
    if (col[i] == 0) dfs(i, 1);
  for (int i = (0); i < (n); ++i)
    printf("%d %d\n", col[a[i].first], col[a[i].second]);
}
int main() {
  sol();
  return 0;
}
