#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
int n;
vector<int> adj[N];
vector<pair<int, int> > r;
int color[N];
bool vis[N];
void solve(int x) {
  vis[x] = true;
  for (auto w : adj[x]) {
    if (!vis[w]) {
      color[w] = (color[x]) ^ 1;
      solve(w);
    }
  }
}
int32_t main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    x--, y--;
    adj[x].push_back(y);
    adj[y].push_back(x);
    int k = 2 * i;
    int kk = 2 * i + 1;
    k %= 2 * n;
    kk %= 2 * n;
    adj[k].push_back(kk);
    adj[kk].push_back(k);
    r.push_back(pair<int, int>(x, y));
  }
  for (int i = 0; i < 2 * n; i++) {
    if (!vis[i]) {
      solve(i);
    }
  }
  for (auto w : r) {
    cout << color[w.first] + 1 << " " << color[w.second] + 1 << endl;
  }
}
