#include <bits/stdc++.h>
using namespace std;
template <typename T>
void sci(T& t) {
  cin >> t;
}
template <typename T, typename... Ts>
void sci(T& t, Ts&... ts) {
  sci(t);
  sci(ts...);
}
vector<pair<int, int> > es;
vector<int> g[222222];
int cc[222222];
void dfs(int v, int c) {
  cc[v] = c;
  for (int i : g[v]) {
    if (cc[i] == 0) {
      dfs(i, 3 - c);
    } else if (cc[i] == c) {
      cout << -1;
      exit(0);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  sci(n);
  for (int i = 0; i < n; i++) {
    int x, y;
    sci(x, y);
    --x;
    --y;
    es.push_back({x, y});
    g[x].push_back(y);
    g[y].push_back(x);
    g[2 * i].push_back(2 * i + 1);
    g[2 * i + 1].push_back(2 * i);
  }
  for (int i = 0; i < 2 * n; i++) {
    if (cc[i] == 0) {
      dfs(i, 1);
    }
  }
  for (int i = 0; i < n; i++) {
    cout << cc[es[i].first] << " " << cc[es[i].second] << "\n";
  }
  return 0;
}
