#include <bits/stdc++.h>
using namespace std;
struct Struct {
  int Boy;
  int Girl;
};
int TotalPoint;
Struct Lovers[200001];
int Col[200001];
bool Visit[200001];
vector<int> Edge[200001];
inline void Dfs(int Now, int Color);
int main(void) {
  register int i;
  cin >> TotalPoint;
  for (i = 1; i <= TotalPoint; i++) {
    cin >> Lovers[i].Boy >> Lovers[i].Girl;
    Edge[Lovers[i].Boy].push_back(Lovers[i].Girl);
    Edge[Lovers[i].Girl].push_back(Lovers[i].Boy);
  }
  for (i = 1; i <= TotalPoint; i++) {
    Edge[2 * i - 1].push_back(2 * i);
    Edge[2 * i].push_back(2 * i - 1);
  }
  for (i = 1; i <= 2 * TotalPoint; i++) {
    if (!Visit[i]) {
      Dfs(i, 1);
    }
  }
  for (i = 1; i <= TotalPoint; i++) {
    cout << Col[Lovers[i].Boy] << ' ' << Col[Lovers[i].Girl] << endl;
  }
  return 0;
}
inline void Dfs(int Now, int Color) {
  Col[Now] = Color;
  Visit[Now] = true;
  register int i;
  for (i = 0; i < Edge[Now].size(); i++) {
    register int Next;
    Next = Edge[Now][i];
    if (!Col[Next]) {
      Dfs(Next, 3 - Color);
    }
  }
}
