#include <bits/stdc++.h>
using namespace std;
int d[1 << 16], s[1 << 16];
vector<pair<int, int> > res;
int resn;
vector<int> c;
int main() {
  int n;
  cin >> n;
  for (int(i) = 0; i < (n); ++i) {
    int x, y;
    cin >> d[i] >> s[i];
  }
  for (int(i) = 0; i < (n); ++i) {
    if (d[i] == 1) c.push_back(i);
  }
  while (c.size()) {
    int k = c.back();
    c.pop_back();
    if (d[k] == 0) continue;
    int id = s[k];
    d[id]--;
    s[id] = s[id] ^ k;
    if (d[id] == 1) c.push_back(id);
    res.push_back(make_pair(k, id));
  }
  cout << res.size() << endl;
  for (int(i) = 0; i < (res.size()); ++i)
    cout << res[i].first << " " << res[i].second << "\n";
  return 0;
}
