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