#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
const int N = 3e5 + 5;
int power(int a, int b) {
  if (!b) return 1;
  int c = power(a, b / 2);
  c = (1LL * c * c) % mod;
  if (b % 2) c = (1LL * c * a) % mod;
  return c;
}
void done() {}
struct segtree {
  int sz;
  vector<ll> sums;
  void init(int n) {
    sz = 1;
    while (sz < n) sz *= 2;
    sums.assign(2 * sz, 0ll);
  }
  void set_v(int i, int v, int x, int lx, int rx) {
    if (rx - lx == 1) {
      sums[x] = v;
      return;
    }
    int m = (lx + rx) / 2;
    if (i < m) {
      set_v(i, v, 2 * x + 1, lx, m);
    } else
      set_v(i, v, 2 * x + 2, m, rx);
    sums[x] = sums[2 * x + 1] + sums[2 * x + 2];
  }
  void set_ar(int i, int v) { set_v(i, v, 0, 0, sz); }
  long long sum(int l, int r, int x, int lx, int rx) {
    if (lx >= r || l >= rx) return 0;
    if (lx >= l && rx <= r) return sums[x];
    int m = (lx + rx) / 2;
    ll s1 = sum(l, r, 2 * x + 1, lx, m);
    ll s2 = sum(l, r, 2 * x + 2, m, rx);
    return s1 + s2;
  }
  long long sum(int l, int r) { return sum(l, r, 0, 0, sz); }
};
void solve() {
  int n, q;
  cin >> n >> q;
  segtree st;
  st.init(n);
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    st.set_ar(i, x);
  }
  while (q--) {
    int ad;
    cin >> ad;
    if (ad == 1) {
      int pos, val;
      cin >> pos >> val;
      st.set_ar(pos, val);
    } else {
      int l, r;
      cin >> l >> r;
      cout << st.sum(l, r) << '\n';
    }
  }
}
void another() {
  int n;
  cin >> n;
  vector<int> to(2 * n), a(n), b(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i] >> b[i];
    --a[i];
    --b[i];
    to[a[i]] = b[i];
    to[b[i]] = a[i];
  }
  vector<int> ans(2 * n, -1);
  for (int i = 0; i < 2 * n; ++i) {
    int u = i;
    if (!~ans[u]) {
      while (1) {
        if (~ans[u]) break;
        ans[u] = 0;
        ans[u ^ 1] = 1;
        u = to[u ^ 1];
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    cout << ans[a[i]] + 1 << ' ' << ans[b[i]] + 1 << '\n';
  }
}
void test_case() {
  int t;
  cin >> t;
  while (t--) another();
}
int main() {
  ios::sync_with_stdio(NULL);
  cin.tie(0);
  cout.tie(0);
  another();
}
