#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline T qmin(const T a, const T b) {
  return a < b ? a : b;
}
template <typename T>
inline T qmax(const T a, const T b) {
  return a > b ? a : b;
}
template <typename T>
inline void getmin(T &a, const T b) {
  if (a > b) a = b;
}
template <typename T>
inline void getmax(T &a, const T b) {
  if (a < b) a = b;
}
inline void fileio(string s) {
  freopen((s + ".in").c_str(), "r", stdin);
  freopen((s + ".out").c_str(), "w", stdout);
}
const int inf = 1e9 + 7;
const long long linf = 1e17 + 7;
const int N = 2e5 + 7;
int q[N], st, ed;
int n, deg[N], s[N];
int tot, ans[N][2];
void dfs(int u) {
  int v = s[u];
  ++tot, ans[tot][0] = u, ans[tot][1] = v;
  --deg[v], s[v] ^= u;
  --deg[u], s[u] = 0;
  if (deg[v] == 1) dfs(v);
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d%d", deg + i, s + i);
  }
  for (int i = 0; i < n; ++i) {
    if (deg[i] == 1) dfs(i);
  }
  printf("%d\n", tot);
  for (int i = 1; i <= tot; ++i) printf("%d %d\n", ans[i][0], ans[i][1]);
  return 0;
}
