#include <bits/stdc++.h>
using namespace std;
int color[200005], n1[200005], n2[200005], n;
vector<int> L[200005];
inline void Dfs(int nod, int c) {
  color[nod] = c;
  for (auto it : L[nod])
    if (color[it] == -1) Dfs(it, (c ^ 1));
}
int main() {
  int i, j, x, y;
  cin >> n;
  for (i = 1; i <= n; ++i) {
    cin >> x >> y;
    n1[i] = x;
    n2[i] = y;
    L[x].push_back(y);
    L[y].push_back(x);
  }
  for (i = 1; i <= n; ++i) {
    L[2 * i - 1].push_back(2 * i);
    L[2 * i].push_back(2 * i - 1);
  }
  n <<= 1;
  for (i = 1; i <= n; ++i) color[i] = -1;
  for (i = 1; i <= n; ++i)
    if (color[i] == -1) Dfs(i, 0);
  for (i = 1; i <= n / 2; ++i)
    cout << 2 - color[n1[i]] << " " << 2 - color[n2[i]] << "\n";
  return 0;
}
