#include <bits/stdc++.h>
using namespace std;
const int MXN = 1e6 + 7;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const double eps = 1e-9;
int n, flag;
int vis[MXN];
std::vector<pair<int, int> > cw;
std::vector<int> son[MXN];
void dfs(int u, int fa, int sta) {
  vis[u] = sta;
  int len = son[u].size();
  for (int i = 0; i < len; ++i) {
    int v = son[u][i];
    if (vis[v] == vis[u])
      flag = 1;
    else if (vis[v] == -1)
      dfs(v, u, !sta);
  }
}
int main() {
  while (~scanf("%d", &n)) {
    cw.resize(n);
    for (int i = 0; i <= n; ++i) son[i].clear();
    for (int i = 0; i < n; ++i) {
      scanf("%d%d", &cw[i].first, &cw[i].second);
      son[cw[i].first].push_back(cw[i].second);
      son[cw[i].second].push_back(cw[i].first);
    }
    for (int i = 1; i < n + n; i += 2) {
      son[i].push_back(i + 1);
      son[i + 1].push_back(i);
    }
    memset((vis), (-1), sizeof((vis)));
    flag = 0;
    for (int i = 0; i < n; ++i) {
      if (vis[cw[i].first] == -1) dfs(cw[i].first, 0, 0);
    }
    if (flag) {
      printf("-1\n");
      continue;
    }
    for (int i = 0; i < n; ++i) {
      printf("%d %d\n", vis[cw[i].first] + 1, vis[cw[i].second] + 1);
    }
  }
  return 0;
}
