#include <bits/stdc++.h>
using namespace std;
int n, d[(1 << 16)], s[(1 << 16)];
queue<int> q;
vector<pair<long long, int> > res;
int main() {
  cin >> n;
  for (long long i = 0; i < (long long)n; i++) {
    cin >> d[i] >> s[i];
    if (d[i] == 1) q.push(i);
  }
  int cnt = 0;
  while (!q.empty()) {
    int v = q.front();
    q.pop();
    int u = s[v];
    if (d[v] == 0 || v == u) continue;
    res.push_back(pair<long long, int>(v, u));
    d[u]--;
    s[u] ^= v;
    if (d[u] == 1) {
      q.push(u);
    }
  }
  cout << res.size() << endl;
  for (long long i = 0; i < (long long)res.size(); i++)
    cout << res[i].first << " " << res[i].second << endl;
  return 0;
}
