#include <bits/stdc++.h>
using namespace std;
const double PI = 3.141592653589793238;
long long powmod(long long a, long long b) {
  long long res = 1;
  a %= 1000000007;
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % 1000000007;
    a = a * a % 1000000007;
  }
  return res;
}
vector<int> vec[200005];
int food[200005], arr[200005], brr[200005];
bool solve(int node, bool fd) {
  food[node] = fd;
  bool flag = false;
  for (int i = 0; i < vec[node].size(); i++) {
    if (food[vec[node][i]] == food[node]) return true;
    if (food[vec[node][i]] == -1) {
      flag |= solve(vec[node][i], !fd);
    }
  }
  return flag;
}
int main() {
  int n;
  bool flag = false;
  memset(food, -1, sizeof(food));
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &arr[i]);
    scanf("%d", &brr[i]);
    vec[arr[i]].push_back(brr[i]);
    vec[brr[i]].push_back(arr[i]);
  }
  for (int i = 1; i <= 2 * n; i += 2) {
    vec[i].push_back(i + 1);
    vec[i + 1].push_back(i);
  }
  for (int i = 1; i <= 2 * n; i++) {
    if (food[i] == -1) {
      flag |= solve(i, 1);
    }
  }
  if (flag) {
    printf("-1\n");
  } else {
    for (int i = 0; i < n; i++) {
      printf("%d %d\n", food[arr[i]] + 1, food[brr[i]] + 1);
    }
  }
  return 0;
}
