#include <bits/stdc++.h>
using namespace std;
const int Max = 70000;
int deg[Max];
int x_or[Max];
int fa[Max];
int n;
queue<int> que;
void input() {
  for (int i = 0; i < n; i++) {
    cin >> deg[i] >> x_or[i];
    if (deg[i] == 1) que.push(i);
  }
  memset(fa, -1, sizeof(fa));
}
void solve() {
  int ans = 0;
  while (!que.empty()) {
    int u = que.front();
    que.pop();
    if (deg[u] == 0) continue;
    fa[u] = x_or[u];
    x_or[fa[u]] ^= u;
    deg[fa[u]]--;
    ans++;
    if (deg[fa[u]] == 1) que.push(fa[u]);
  }
  cout << ans << endl;
}
void output() {
  for (int i = 0; i < n; i++) {
    if (fa[i] != -1) {
      cout << i << " " << fa[i] << endl;
    }
  }
}
int main() {
  cin >> n;
  input();
  solve();
  output();
  return 0;
}
