#include <bits/stdc++.h>
using namespace std;
vector<int> a, b;
vector<vector<int>> adjlist;
vector<int> colors;
void visit(int v, int c) {
  colors[v] = c;
  for (int w : adjlist[v])
    if (!colors[w]) visit(w, c == 1 ? 2 : 1);
}
int main() {
  int n;
  scanf("%d", &n);
  a.resize(n);
  b.resize(n);
  adjlist.resize(2 * n);
  for (int i = 0; i < n; i++) {
    scanf("%d %d", &a[i], &b[i]);
    a[i]--;
    b[i]--;
    adjlist[a[i]].push_back(b[i]);
    adjlist[b[i]].push_back(a[i]);
  }
  for (int i = 0; i < 2 * n; i += 2) {
    adjlist[i].push_back(i + 1);
    adjlist[i + 1].push_back(i);
  }
  colors.resize(2 * n);
  for (int i = 0; i < 2 * n; i++) {
    if (!colors[i]) {
      visit(i, 1);
    }
  }
  for (int i = 0; i < n; i++) {
    printf("%d %d\n", colors[a[i]], colors[b[i]]);
  }
  return 0;
}
