#include <bits/stdc++.h>
using namespace std;
int n, ai, bi;
vector<vector<int> > adj(200009);
vector<int> vis(200009, 0);
vector<pair<int, int> > se;
void dfs(int v, int vl) {
  if (vis[v]) return;
  vis[v] = vl;
  vl = (vl == 1) ? 2 : 1;
  int len = adj[v].size();
  for (int i = 0; i < len; i++) dfs(adj[v][i], vl);
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> ai >> bi;
    se.push_back(make_pair(ai, bi));
    adj[ai].push_back(bi);
    adj[bi].push_back(ai);
    adj[(2 * i)].push_back(2 * i + 1);
    adj[(2 * i + 1)].push_back(2 * i);
  }
  for (int i = 1; i <= 2 * n; i++)
    if (!vis[i]) dfs(i, 1);
  for (int i = 0; i < n; i++)
    cout << vis[se[i].first] << " " << vis[se[i].second] << "\n";
}
