#include <bits/stdc++.h>
using namespace std;
const int M = 2e5 + 5;
bool Ans[M], mark[M];
vector<int> adj[M];
vector<pair<long long, long long> > vec;
void dfs(int x, int cnt) {
  mark[x] = 1;
  for (int i = 0; i < adj[x].size(); i++) {
    int child = adj[x][i];
    if (!mark[child]) dfs(child, cnt + 1);
  }
  Ans[x] = cnt & 1;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int fi, se;
    cin >> fi >> se;
    vec.push_back(make_pair(fi, se));
    adj[fi].push_back(se), adj[se].push_back(fi);
    adj[2 * i - 1].push_back(2 * i), adj[2 * i].push_back(2 * i - 1);
  }
  for (int i = 1; i <= 2 * n; i++)
    if (!mark[i]) dfs(i, 0);
  for (int i = 0; i < n; i++)
    cout << Ans[vec[i].first] + 1 << " " << Ans[vec[i].second] + 1 << endl;
  return 0;
}
