#include <bits/stdc++.h>
using namespace std;
using Node = pair<int, int>;
constexpr int MAXN = 1000005;
int N;
vector<int> mark(MAXN, 0);
vector<Node> var(MAXN);
vector<vector<int>> graph(2 * MAXN);
void GetAns(int u, int s) {
  mark[u] = s;
  for (auto v : graph[u]) {
    if (!mark[v]) {
      GetAns(v, s ^ 1);
    }
  }
}
int main() {
  scanf("%d", &N);
  for (int i = 1; i <= N; ++i) {
    scanf("%d%d", &var[i].first, &var[i].second);
    graph[var[i].first].push_back(var[i].second);
    graph[var[i].second].push_back(var[i].first);
    graph[2 * i - 1].push_back(2 * i);
    graph[2 * i].push_back(2 * i - 1);
  }
  for (int i = 1; i <= 2 * N; ++i) {
    if (!mark[i]) {
      GetAns(i, 0);
    }
  }
  for (int i = 1; i <= N; ++i) {
    printf("%d %d\n", mark[var[i].first] + 1, mark[var[i].second] + 1);
  }
  return 0;
}
