#include <bits/stdc++.h>
using namespace std;
using ld = long double;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
const int oo = 1e9 + 7;
const ll loo = 1e18;
ll modpow(ll a, ll b) {
  ll res = 1;
  while (b) {
    if (b & 1) res = res * a % oo;
    a = a * a % oo;
    b /= 2;
  }
  return res;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N = 2e5;
int n;
vector<int> adj[N];
bool vis[N];
int a[N], b[N], c[N];
void addEdge(int v, int w) {
  adj[v].push_back(w);
  adj[w].push_back(v);
}
void dfs(int v, int col) {
  vis[v] = 1;
  c[v] = col;
  for (int w : adj[v]) {
    if (!vis[w]) dfs(w, col ^ 1);
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
    addEdge(--a[i], --b[i]);
    addEdge(i << 1, i << 1 | 1);
  }
  for (int i = 0; i < 2 * n; i++)
    if (!vis[i]) {
      dfs(i, 0);
    }
  stringstream ss;
  for (int i = 0; i < n; i++) ss << c[a[i]] + 1 << " " << c[b[i]] + 1 << endl;
  cout << ss.str();
  return 0;
}
