#include <bits/stdc++.h>
using namespace std;
vector<int> v[1000007];
int color[1000006];
int arr[1000005][3];
int visited[1000006];
int vertex;
int flg = 0;
void bfs(int f) {
  queue<int> q;
  int i;
  q.push(f);
  color[f] = 1;
  while (!q.empty()) {
    int x = q.front();
    q.pop();
    visited[x] = 1;
    for (i = 0; i < v[x].size(); i++) {
      if (visited[v[x][i]] == 0) {
        visited[v[x][i]] = 1;
        if (color[x] == 1)
          color[v[x][i]] = 2;
        else
          color[v[x][i]] = 1;
        q.push(v[x][i]);
      } else {
        if (color[x] == color[v[x][i]]) {
          flg = 1;
          break;
        }
      }
      if (flg == 1) break;
    }
    if (flg == 1) break;
  }
}
int main() {
  cin >> vertex;
  int i, a, b;
  for (i = 1; i <= vertex; i++) {
    cin >> a >> b;
    v[a].push_back(b);
    v[b].push_back(a);
    arr[i][0] = a;
    arr[i][1] = b;
  }
  i = 1;
  while (i <= 2 * vertex - 1) {
    v[i].push_back(i + 1);
    v[i + 1].push_back(i);
    i = i + 2;
  }
  for (i = 0; i <= 2 * vertex; i++) {
    color[i] = 0;
    visited[i] = 0;
  }
  for (i = 1; i <= 2 * vertex; i++) {
    if (visited[i] == 0) bfs(i);
    if (flg == 1) break;
  }
  if (flg == 1)
    cout << "-1" << endl;
  else {
    for (i = 1; i <= vertex; i++) {
      cout << color[arr[i][0]] << " " << color[arr[i][1]] << endl;
    }
  }
  return 0;
}
