#include <bits/stdc++.h>
using namespace std;
const int N = int(1e6);
int col[N];
int to[N], ant[N], adj[N], z;
void dfs(int u) {
  for (int i = adj[u]; i != -1; i = ant[i]) {
    if (col[to[i]] == -1) {
      col[to[i]] = col[u] ^ 1;
      dfs(to[i]);
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  memset(col, -1, sizeof col);
  memset(adj, -1, sizeof adj);
  z = 0;
  int n;
  cin >> n;
  int a, b;
  vector<pair<int, int> > p;
  for (int i = 0; i < n; ++i) {
    cin >> a >> b;
    --a, --b;
    to[z] = b;
    ant[z] = adj[a];
    adj[a] = z++;
    to[z] = a;
    ant[z] = adj[b];
    adj[b] = z++;
    p.push_back({a, b});
  }
  for (int i = 0; i < 2 * n; ++i) {
    to[z] = i + 1;
    ant[z] = adj[i];
    adj[i] = z++;
    to[z] = i;
    ant[z] = adj[i + 1];
    adj[i + 1] = z++;
    ++i;
  }
  for (int i = 0; i < 2 * n; ++i) {
    if (col[i] == -1) {
      col[i] = 0;
      dfs(i);
    }
  }
  for (int i = 0; i < n; ++i) {
    cout << col[p[i].first] + 1 << ' ' << col[p[i].second] + 1 << '\n';
  }
  return 0;
}
