#include <bits/stdc++.h>
template <class T>
inline void rd(T &x) {
  char c = getchar();
  x = 0;
  while (!isdigit(c)) c = getchar();
  while (isdigit(c)) {
    x = x * 10 + c - '0';
    c = getchar();
  }
}
using namespace std;
const int N = 2e5 + 11;
const int M = 531;
pair<int, int> a[N];
vector<int> e[N];
int use[N], flag = 1;
void dfs(int x, int fa, int col) {
  use[x] = col + 1;
  for (auto v : e[x])
    if (v != fa) {
      if (!use[v])
        dfs(v, x, col ^ 1);
      else if (use[v] != (col ^ 1) + 1) {
        flag = 0;
        return;
      }
    }
}
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i].first);
    scanf("%d", &a[i].second);
    e[a[i].first].push_back(a[i].second);
    e[a[i].second].push_back(a[i].first);
    e[2 * i].push_back(2 * i + 1);
    e[2 * i + 1].push_back(2 * i);
  }
  for (int i = 0; i < 2 * n; i++)
    if (!use[i]) dfs(i, -1, 0);
  if (flag) {
    for (int i = 0; i < n; i++)
      printf("%d %d\n", use[a[i].first], use[a[i].second]);
  } else
    puts("-1");
  return 0;
}
