#include <bits/stdc++.h>
using namespace std;
struct point {
  int x;
  int y;

 public:
  point() { ; }

 public:
  point(int a, int b) {
    x = a;
    y = b;
  }
};
const bool operator<(const point &a, const point &b) {
  if (a.x != b.x) {
    return a.x < b.x;
  } else {
    return a.y < b.y;
  }
}
const bool comp2(const point &a, const point &b) {
  return a.y - a.x < b.y - b.x;
}
vector<int> result;
vector<bool> visited;
void DFS(vector<int> &a, int n) {
  int temp = n;
  if (!visited[a[temp]]) {
    result[a[temp]] = result[temp] + 1;
    visited[a[temp]] = true;
    DFS(a, a[temp]);
  }
  if (temp % 2 == 0 && temp < a.size() - 1 && !visited[temp + 1]) {
    result[temp + 1] = result[temp] + 1;
    visited[temp + 1] = true;
    DFS(a, temp + 1);
  }
  if (temp % 2 == 1 && temp > 0 && !visited[temp - 1]) {
    result[temp - 1] = result[temp] + 1;
    visited[temp - 1] = true;
    DFS(a, temp - 1);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> a(2 * n);
  vector<int> b(2 * n);
  visited.resize(a.size());
  result.resize(a.size());
  for (int i = 0; i < n; i++) {
    cin >> b[i * 2] >> b[i * 2 + 1];
    b[i * 2]--, b[i * 2 + 1]--;
    a[b[i * 2]] = b[i * 2 + 1];
    a[b[i * 2 + 1]] = b[i * 2];
  }
  for (int i = 0; i < 2 * n; i++) {
    if (!visited[i]) {
      visited[i] = true;
      result[i] = 0;
      DFS(a, i);
    }
  }
  for (int i = 0; i < b.size(); i += 2) {
    cout << (result[b[i]] % 2 == 0 ? 2 : 1) << " "
         << (result[b[i + 1]] % 2 == 0 ? 2 : 1) << endl;
  }
  return 0;
}
