#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 200333;
int a[MAX_N];
bool inSet[MAX_N];
pair<int, int> pairs[MAX_N];
int n;
bool randValue[MAX_N];
int b[MAX_N];
int getId(const int& pos) {
  return (pos > n) ? pos - n : (pos <= 0) ? n + pos : pos;
}
int getValue(const int& pos) {
  return b[(pos > n) ? pos - n : (pos <= 0) ? n + pos : pos];
}
bool isOk(int pos) {
  int tmp = getValue(pos);
  return ((tmp != getValue(pos + 1) || tmp != getValue(pos + 2)) &&
          (tmp != getValue(pos - 1) || tmp != getValue(pos + 1)) &&
          (tmp != getValue(pos - 1) || tmp != getValue(pos - 2)));
}
bool tryChange(int v) {
  b[v] ^= 1;
  b[a[v]] ^= 1;
  if (isOk(a[v]) && isOk(v)) {
    return true;
  }
  b[v] ^= 1;
  b[a[v]] ^= 1;
  return false;
}
int rid = 0;
bool getRand() {
  rid++;
  if (rid >= MAX_N) {
    rid = 0;
  }
  return randValue[rid];
}
int shaffledList[128];
int shaffledCnt = 0;
void doLocalShaffle(int pos, int depth = 0) {
  if (depth == 2) {
    return;
  }
  shaffledList[++shaffledCnt] = pos;
  shaffledList[++shaffledCnt] = a[pos];
  if (getRand()) {
    b[a[pos]] ^= 1;
    b[pos] ^= 1;
  }
  doLocalShaffle(getId(pos + 1), depth + 1);
  doLocalShaffle(getId(pos - 1), depth + 1);
}
deque<int> q;
void checkShaffled() {
  for (int i = 1; i <= shaffledCnt; i++) {
    int v = shaffledList[i];
    for (int u = v - 2; u <= v; u++) {
      if (getValue(u) == getValue(u + 1) && getValue(u) == getValue(u + 2)) {
        inSet[getId(u)] = true;
        q.push_back(getId(u));
      } else {
        inSet[getId(u)] = false;
      }
    }
  }
}
int main(int argc, const char* argv[]) {
  for (int i = 1; i < MAX_N; i++) {
    randValue[i] = rand() & 1;
  }
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int x, y;
    cin >> x >> y;
    a[x] = y;
    a[y] = x;
    pairs[i] = {x, y};
    if (randValue[i]) {
      b[x] = 1, b[y] = 0;
    } else {
      b[y] = 1, b[x] = 0;
    }
  }
  n *= 2;
  for (int i = 1; i <= n; i++) {
    if (getValue(i) == getValue(i + 1) && getValue(i + 1) == getValue(i + 2)) {
      inSet[i] = true;
      q.push_back(i);
    }
  }
  while (!q.empty()) {
    int v = getId(q.front());
    q.pop_front();
    if (!inSet[v]) {
      continue;
    }
    if (tryChange(getId(v + 1))) {
      inSet[v] = false;
      continue;
    }
    if (tryChange(getId(v))) {
      inSet[v] = false;
      continue;
    }
    if (tryChange(getId(v + 2))) {
      inSet[v] = false;
      continue;
    }
    shaffledCnt = 0;
    doLocalShaffle(getId(v + 1));
    checkShaffled();
  }
  n /= 2;
  for (int i = 1; i <= n; i++) {
    cout << b[pairs[i].first] + 1 << ' ' << b[pairs[i].second] + 1 << '\n';
  }
  return 0;
}
