#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> d, second;
stack<int> t;
vector<pair<int, int> > ans;
void solve() {
  while (!t.empty()) {
    int i = t.top();
    t.pop();
    if (d[i] == 0) continue;
    d[i]--, d[second[i]]--;
    if (d[second[i]] == 1) t.push(second[i]);
    ans.push_back({i, second[i]});
    second[second[i]] ^= i;
  }
  cout << ans.size() << '\n';
  for (auto i : ans) cout << i.first << ' ' << i.second << '\n';
  return;
}
void inp() {
  cin >> n;
  d.resize(n), second.resize(n);
  for (int i = 0; i < n; i++) {
    cin >> d[i] >> second[i];
    if (d[i] == 1) t.push(i);
  }
  return;
}
int main() {
  clock_t beg = clock();
  {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
  };
  inp();
  solve();
  clock_t end = clock();
  fprintf(stderr, "%.3f sec\n", (double)(end - beg) / CLOCKS_PER_SEC);
  return 0;
}
