#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base ::sync_with_stdio(false);
  ;
  cin.tie(NULL);
  ;
  long long int t = 1;
  while (t--) {
    long long int n;
    cin >> n;
    pair<long long int, long long int> tree[n];
    long long int i, j, k;
    map<pair<long long int, long long int>, long long int> mp;
    for (i = 0; i < n; i++) {
      cin >> j >> k;
      tree[i].first = j;
      tree[i].second = k;
    }
    list<long long int> l;
    for (i = 0; i < n; i++) {
      if (tree[i].first == 1) l.push_back(i);
    }
    vector<pair<long long int, long long int> > edges;
    while (!l.empty()) {
      long long int node = l.front();
      l.pop_front();
      if (tree[node].first == 0) continue;
      long long int xors = tree[node].second;
      tree[xors].first--;
      tree[xors].second ^= node;
      edges.push_back({node, xors});
      if (tree[xors].first == 1) l.push_back(xors);
    }
    cout << edges.size() << endl;
    for (auto x : edges) cout << x.first << " " << x.second << endl;
  }
}
