#include <bits/stdc++.h>
using namespace std;
pair<int, int> arr[1 << 16];
int main() {
  int n;
  cin >> n;
  queue<int> q;
  vector<pair<int, int> > ans;
  for (int i = 0; i < n; i++) {
    cin >> arr[i].first >> arr[i].second;
    if (arr[i].first == 1) q.push(i);
  }
  while (q.size()) {
    int f = q.front();
    q.pop();
    if (arr[f].first != 1) continue;
    int t = arr[f].second;
    arr[t].first--, arr[t].second ^= f;
    if (arr[t].first == 1) q.push(t);
    ans.push_back(make_pair((f), (t)));
  }
  cout << ans.size() << "\n";
  for (int i = 0; i < ans.size(); i++)
    cout << ans[i].first << " " << ans[i].second << "\n";
  return 0;
}
