#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T bigmod(T p, T e, T M) {
  if (e == 0) return 1;
  if (e % 2 == 0) {
    T t = bigmod(p, e / 2, M);
    return (t * t) % M;
  }
  return (bigmod(p, e - 1, M) * p) % M;
}
template <class T>
inline T gcd(T a, T b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
template <class T>
inline T modinverse(T a, T M) {
  return bigmod(a, M - 2, M);
}
template <class T>
inline T multimod(T a, T b, T m) {
  T ans = 0ll;
  a %= m, b %= m;
  while (b) {
    if (b & 1ll) ans = m - ans > a ? (ans + a) : (ans + a - m);
    b >>= 1ll;
    a = (m - a) > a ? a + a : a + a - m;
  }
  return (T)ans;
}
bool ok;
int vis[(200000 + 7)];
vector<int> V[(200000 + 7)];
void DFS(int u, int c) {
  if (vis[u]) {
    if (vis[u] != c) {
      ok = 1;
      return;
    }
    return;
  }
  vis[u] = c;
  for (int i = 0; i < V[u].size(); i++) {
    int v = V[u][i];
    DFS(v, c % 2 + 1);
  }
  return;
}
int a[(200000 + 7)];
int b[(200000 + 7)];
int main() {
  int n, e, i, u, v;
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> a[i] >> b[i];
    V[a[i]].push_back(b[i]);
    V[b[i]].push_back(a[i]);
  }
  for (i = 1; i < 2 * n; i += 2) {
    V[i].push_back(i + 1);
    V[i + 1].push_back(i);
  }
  ok = 0;
  for (i = 1; i <= 2 * n; i++) {
    if (!vis[i]) {
      DFS(i, 1);
    }
  }
  if (ok) {
    cout << -1 << endl;
    return 0;
  }
  for (i = 1; i <= n; i++) {
    cout << vis[a[i]] << " " << vis[b[i]] << endl;
  }
  return 0;
}
