#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int arr[n], degree[n];
  vector<pair<int, int> > edges;
  stack<int> s1;
  for (int i = 0; i < n; i++) {
    cin >> degree[i] >> arr[i];
    if (degree[i] == 1) s1.push(i);
  }
  long long ans = 0;
  while (!s1.empty()) {
    int node = s1.top();
    s1.pop();
    if (degree[node] != 0) {
      int val = arr[node];
      edges.push_back(pair<int, int>(node, val));
      ans++;
      degree[val]--;
      degree[node]--;
      arr[val] = arr[val] ^ node;
      if (degree[val] == 1) s1.push(val);
    }
  }
  cout << ans << endl;
  for (int i = 0; i < edges.size(); i++)
    cout << edges[i].first << " " << edges[i].second << endl;
  return 0;
}
