#include <bits/stdc++.h>
using namespace std;
const int inf = 1 << 30;
const int N = 200100;
int n, a[N], q;
vector<int> adj[N];
int col[N];
void dfs(int u, int c) {
  col[u] = c;
  for (auto v : adj[u]) {
    if (col[v] == -1) {
      dfs(v, 1 - c);
    }
  }
}
vector<pair<int, int> > v;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    int x, y;
    scanf("%d %d", &x, &y);
    adj[x].push_back(y);
    adj[y].push_back(x);
    v.push_back({x, y});
  }
  for (int i = 1; i < n; i++) {
    adj[2 * i].push_back(2 * i + 1);
    adj[2 * i + 1].push_back(2 * i);
  }
  memset(col, -1, sizeof col);
  for (int i = 1; i <= n + n; i++) {
    if (col[i] == -1) dfs(i, 1);
  }
  for (auto x : v) {
    printf("%d %d\n", ++col[x.first], ++col[x.second]);
  }
  return 0;
}
