#include <bits/stdc++.h>
using namespace std;
const int N = 200010;
vector<int> g[N];
int n, col[N], u[N], v[N];
void Bfs(int x) {
  queue<int> q;
  q.push(x);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int i = 0; i < g[u].size(); i++) {
      int v = g[u][i];
      if (!col[v]) {
        if (col[u] == 1)
          col[v] = 2;
        else
          col[v] = 1;
        q.push(v);
      } else if (col[v] == col[u]) {
        puts("-1");
        exit(0);
      }
    }
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &u[i], &v[i]);
    g[u[i]].push_back(v[i]);
    g[v[i]].push_back(u[i]);
  }
  for (int i = 1; i <= 2 * n; i += 2) {
    g[i].push_back(i + 1);
    g[i + 1].push_back(i);
  }
  for (int i = 1; i <= n * 2; i++) {
    if (col[i]) continue;
    if (col[i - 1] == 1)
      col[i] = 2;
    else
      col[i] = 1;
    Bfs(i);
  }
  for (int i = 1; i <= n; i++) printf("%d %d\n", col[u[i]], col[v[i]]);
}
