#include <bits/stdc++.h>
using namespace std;
const int MN = 1 << 17;
int deg[MN], sum[MN];
vector<int> ke[MN];
int main() {
  ios ::sync_with_stdio(false);
  cout << (fixed) << setprecision(9);
  int n;
  while (cin >> n) {
    for (int i = 0, _a = (n); i < _a; i++) ke[i].clear();
    set<pair<int, int> > s;
    for (int i = 0, _a = (n); i < _a; i++) {
      cin >> deg[i] >> sum[i];
      s.insert(make_pair(deg[i], i));
    }
    int m = 0;
    while (!s.empty()) {
      int u = s.begin()->second;
      s.erase(s.begin());
      if (deg[u] == 0) continue;
      if (deg[u] == 1) {
        int v = sum[u];
        ke[u].push_back(v);
        ++m;
        --deg[u];
        s.erase(make_pair(deg[v], v));
        --deg[v];
        sum[v] ^= u;
        s.insert(make_pair(deg[v], v));
      }
    }
    cout << m << "\n";
    for (int i = 0, _a = (n); i < _a; i++)
      if (ke[i].size()) {
        for (auto x : ke[i]) cout << i << ' ' << x << "\n";
      }
  }
  return 0;
}
