#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 10;
const int MOD = 1e9 + 7;
const int inf = 1e9;
int n, m, cnt[maxn];
vector<int> g[maxn];
int vis[maxn];
vector<pair<int, int> > e;
void dfs(int v, int c) {
  vis[v] = c;
  for (auto i : g[v]) {
    if (!vis[i]) {
      if (c == 1)
        dfs(i, 2);
      else
        dfs(i, 1);
    }
  }
}
void solve() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    int u, v;
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
    e.push_back(make_pair(u, v));
  }
  for (int i = 1; i < 2 * n; i += 2) {
    g[i].push_back(i + 1);
    g[i + 1].push_back(i);
  }
  for (int i = 1; i <= 2 * n; i++) {
    if (!vis[i]) {
      dfs(i, 1);
    }
  }
  for (auto i : e) {
    cout << vis[i.first] << ' ' << vis[i.second] << '\n';
  }
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  int test = 1;
  while (test--) {
    solve();
  }
  return 0;
}
