#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> Adj[200005];
vector<pair<int, int>> Pairs;
vector<int> visited;
bool ok = true;
void DFS(int node, int color) {
  visited[node] = color;
  for (const int& x : Adj[node])
    if (visited[x] == 0)
      DFS(x, 3 - color);
    else if (visited[x] == visited[node]) {
      ok = false;
      cout << "-1";
      return;
    }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  Pairs.resize(n + 2);
  visited.resize(2 * n + 2);
  for (int i = 1; i <= n; ++i) {
    cin >> Pairs[i].first >> Pairs[i].second;
    Adj[Pairs[i].first].push_back(Pairs[i].second);
    Adj[Pairs[i].second].push_back(Pairs[i].first);
    if (i != n)
      Adj[2 * i].push_back(2 * i + 1), Adj[2 * i + 1].push_back(2 * i);
    else
      Adj[1].push_back(2 * i), Adj[2 * i].push_back(1);
  }
  for (int i = 1; i <= 2 * n; ++i)
    if (visited[i] == 0) DFS(i, 1);
  if (ok)
    for (int i = 1; i <= n; ++i)
      cout << visited[Pairs[i].first] << " " << visited[Pairs[i].second]
           << "\n";
  return 0;
}
