#include <bits/stdc++.h>
using namespace std;
template <class T1>
void deb(T1 e1) {
  cout << e1 << endl;
}
template <class T1, class T2>
void deb(T1 e1, T2 e2) {
  cout << e1 << " " << e2 << endl;
}
template <class T1, class T2, class T3>
void deb(T1 e1, T2 e2, T3 e3) {
  cout << e1 << " " << e2 << " " << e3 << endl;
}
template <class T1, class T2, class T3, class T4>
void deb(T1 e1, T2 e2, T3 e3, T4 e4) {
  cout << e1 << " " << e2 << " " << e3 << " " << e4 << endl;
}
template <class T1, class T2, class T3, class T4, class T5>
void deb(T1 e1, T2 e2, T3 e3, T4 e4, T5 e5) {
  cout << e1 << " " << e2 << " " << e3 << " " << e4 << " " << e5 << endl;
}
template <class T1, class T2, class T3, class T4, class T5, class T6>
void deb(T1 e1, T2 e2, T3 e3, T4 e4, T5 e5, T6 e6) {
  cout << e1 << " " << e2 << " " << e3 << " " << e4 << " " << e5 << " " << e6
       << endl;
}
int n, nn;
int ans[2 * 100000 + 7];
pair<int, int> arr[100000 + 7];
vector<int> edges[2 * 100000 + 7];
void dfs(int u, int pre, int col) {
  int v, sz, i, j, k;
  sz = edges[u].size();
  ans[u] = col;
  for (i = 0; i < sz; i++) {
    v = edges[u][i];
    if (v == pre or ans[v] != -1) continue;
    dfs(v, u, col ^ 1);
  }
}
int main() {
  int u, v, i, j, k;
  scanf("%d", &n);
  nn = n + n;
  memset((ans), -1, sizeof(ans));
  for (i = 1; i <= n; i++) {
    scanf("%d %d", &u, &v);
    arr[i] = make_pair(u, v);
    edges[u].push_back(v);
    edges[v].push_back(u);
    if (i < n) {
      edges[2 * i].push_back(2 * i + 1);
      edges[2 * i + 1].push_back(2 * i);
    }
  }
  for (i = 1; i <= nn; i++) {
    if (ans[i] == -1) {
      dfs(i, 0, 0);
    }
  }
  for (i = 1; i <= n; i++) {
    printf("%d %d\n", ans[arr[i].first] + 1, ans[arr[i].second] + 1);
  }
  return 0;
}
