#include <bits/stdc++.h>
const int MaxN = 200005;
const int MaxE = MaxN << 2;
struct edge_t {
  int to;
  edge_t* next;
} edges[MaxE], *cure;
inline void add_edge(edge_t** head, int u, int v) {
  cure->to = v;
  cure->next = head[u];
  head[u] = cure++;
}
edge_t* head[MaxN];
int res[MaxN][2];
int color[MaxN], queue[MaxN];
std::pair<int, int> id[MaxN];
void bfs(int u) {
  int b = 0, f = 0, v;
  queue[b++] = u;
  color[u] = 0;
  while (f != b) {
    u = queue[f++];
    res[id[u].first][id[u].second] = color[u];
    for (edge_t* it = head[u]; it; it = it->next) {
      v = it->to;
      if (color[v] == -1) {
        color[v] = color[u] ^ 1;
        queue[b++] = v;
      }
    }
  }
}
int main() {
  int n, u, v;
  while (scanf("%d", &n) == 1) {
    std::fill(head, head + n, (edge_t*)NULL);
    cure = edges;
    for (int i = 0; i < n; i++) {
      scanf("%d%d", &u, &v);
      u--;
      v--;
      add_edge(head, u, v);
      add_edge(head, v, u);
      id[u] = {i, 0};
      id[v] = {i, 1};
    }
    for (int i = 0; i < n; i++) {
      add_edge(head, 2 * i, 2 * i + 1);
      add_edge(head, 2 * i + 1, 2 * i);
    }
    std::fill(color, color + 2 * n, -1);
    for (int i = 0; i < 2 * n; i++) {
      if (color[i] == -1) bfs(i);
    }
    for (int i = 0; i < n; i++) printf("%d %d\n", res[i][0] + 1, res[i][1] + 1);
  }
  return 0;
}
