#include <bits/stdc++.h>
using namespace std;
vector<int> d[2 * 100000 + 10];
bool b[2 * 100000 + 10], mark[2 * 100000 + 10];
void dfs(int x, bool c) {
  if (mark[x] == 0) {
    mark[x] = 1, b[x] = c;
    for (int i = 0; i < d[x].size(); i++) dfs(d[x][i], !c);
  }
}
int main() {
  int n;
  cin >> n;
  int p1[n + 10], p2[n + 10];
  d[0].push_back(1);
  d[1].push_back(0);
  for (int i = 0; i < n; i++) {
    cin >> p1[i] >> p2[i];
    d[i * 2].push_back(i * 2 + 1);
    d[i * 2 + 1].push_back(i * 2);
    d[--p1[i]].push_back(--p2[i]);
    d[p2[i]].push_back(p1[i]);
  }
  for (int i = 0; i < 2 * n; i++) dfs(i, 0);
  for (int i = 0; i < n; i++)
    cout << b[p1[i]] + 1 << " " << b[p2[i]] + 1 << endl;
}
