#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000 * 1000 + 10;
const int maxn5 = 3 * 100 * 1000 + 10;
const long long mod = 998244353;
const long long inf = 1LL * 2 * 1000 * 1000 * 1000 * 1000 * 1000 * 1000 + 10;
vector<int> adj[maxn5];
bool mark[maxn5];
vector<pair<int, int> > joft;
int food[maxn5];
void dfs(int v, int c) {
  food[v] = c;
  mark[v] = true;
  for (auto u : adj[v])
    if (!mark[u]) dfs(u, c == 1 ? 2 : 1);
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    adj[a].push_back(b);
    adj[b].push_back(a);
    adj[a].push_back(a % 2 == 0 ? a - 1 : a + 1);
    adj[b].push_back(b % 2 == 0 ? b - 1 : b + 1);
    joft.push_back(make_pair(a, b));
  }
  for (int i = 1; i <= 2 * n; i++)
    if (!mark[i]) dfs(i, 1);
  for (auto u : joft) cout << food[u.first] << ' ' << food[u.second] << '\n';
  return 0;
}
