#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > g;
int visited[300005];
int color[300005];
int flag;
void dfs(int u, int col) {
  visited[u] = 1;
  color[u] = col;
  for (int i = 0; i < g[u].size(); i++) {
    if (!visited[g[u][i]]) {
      dfs(g[u][i], col ^ 1);
    } else {
      if (color[g[u][i]] ^ 1 != color[u]) {
        flag = 1;
      }
    }
  }
}
vector<pair<int, int> > vec;
int main() {
  int n;
  cin >> n;
  g.resize(2 * n);
  for (int i = 0; i < n; i++) {
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    g[u].push_back(v);
    g[v].push_back(u);
    g[2 * i].push_back(2 * i + 1);
    g[2 * i + 1].push_back(2 * i);
    vec.push_back(make_pair(u, v));
  }
  for (int i = 0; i < 2 * n; i++) {
    if (!visited[i]) {
      dfs(i, 0);
    }
  }
  if (flag == 0) {
    for (int i = 0; i < n; i++) {
      cout << color[vec[i].first] + 1 << " " << color[vec[i].second] + 1
           << endl;
    }
  } else {
    cout << -1 << endl;
  }
  return 0;
}
