#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
double PI = 4 * atan(1);
vector<int> adj[200001];
int food[200001];
void dfs(int node, int fo) {
  if (food[node]) return;
  food[node] = fo;
  for (int i : adj[node]) dfs(i, (fo % 2) + 1);
}
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++)
    adj[2 * i + 1].push_back(2 * i + 2), adj[2 * i + 2].push_back(2 * i + 1);
  vector<pair<int, int> > p;
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    adj[x].push_back(y);
    adj[y].push_back(x);
    p.push_back(make_pair(x, y));
  }
  for (int i = 1; i < 2 * n + 1; i++) dfs(i, 1);
  for (int i = 0; i < n; i++)
    cout << food[p[i].first] << " " << food[p[i].second] << "\n";
}
