#include <bits/stdc++.h>
using namespace std;
template <typename P, unsigned long long int mod>
class Mod {
 public:
  Mod() : v_() {}

 public:
  template <typename V>
  P& operator=(const V&& rv) {
    static_assert(std::is_integral<V>::value, "should be integral type");
    v_ = rv;
    return v_;
  }
  template <typename V>
  P& operator+=(const V&& rv) {
    static_assert(std::is_integral<V>::value, "should be integral type");
    v_ += rv;
    return v_;
  }

 private:
  P v_;
};
const int sz = 1e5;
int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<pair<int, int>> couple(n);
  vector<vector<int>> edge(n * 2);
  for (int i = 0; i < n; ++i) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    edge[a].push_back(b);
    edge[b].push_back(a);
    couple[i] = make_pair(a, b);
  }
  for (int i = 0; i < n * 2; i += 2) {
    edge[i].push_back((i + 1) % (n * 2));
    edge[(i + 1) % (n * 2)].push_back(i);
  }
  vector<bool> group(n * 2);
  vector<bool> passed(n * 2);
  for (int i = 0; i < n * 2; ++i) {
    if (passed[i]) {
      continue;
    }
    passed[i] = true;
    queue<int> walk;
    group[i] = true;
    walk.push(i);
    do {
      int now = walk.front();
      walk.pop();
      for (int to : edge[now]) {
        if (passed[to] == false) {
          walk.push(to);
          passed[to] = true;
          group[to] = group[now] ? false : true;
        }
      }
    } while (!walk.empty());
  }
  for (pair<int, int> x : couple) {
    cout << group[x.first] + 1 << " " << group[x.second] + 1 << endl;
  }
}
