#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> adj[210000];
int p[210000];
bool Selected[210000];
int ans[210000];
vector<pair<int, int> > K;
void dfs(int u, int cur) {
  ans[u] = cur;
  Selected[u] = 1;
  for (int i = 0; i < adj[u].size(); i++) {
    int v = adj[u][i];
    if (!Selected[v]) dfs(v, cur ^ 1);
  }
}
int main() {
  cin >> n;
  int u, v;
  int top = 0;
  for (int i = 1; i <= n; i++) {
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
    p[u] = v;
    p[v] = u;
    K.push_back(pair<int, int>(u, v));
  }
  for (int i = 1; i <= n; i++) {
    int u = p[i * 2 - 1];
    int v = p[i * 2];
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  for (int u = 1; u <= n * 2; u++)
    if (!Selected[u]) dfs(u, 0);
  for (int i = 0; i < n; i++)
    cout << ans[K[i].first] + 1 << " " << ans[K[i].second] + 1 << endl;
}
