#include <bits/stdc++.h>
using namespace std;
const int maxn = (1 << 16) + 100;
int n;
int deg[maxn], s[maxn];
vector<pair<int, int> > edges;
struct comp {
  bool operator()(int a, int b) {
    if (deg[a] != deg[b]) return deg[a] < deg[b];
    return a < b;
  }
};
set<int, comp> sit;
int main() {
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> deg[i] >> s[i];
    sit.insert(i);
  }
  while (!sit.empty()) {
    int leaf = *(sit.begin());
    sit.erase(leaf);
    if (!deg[leaf]) continue;
    int par = s[leaf];
    edges.push_back(make_pair(leaf, par));
    sit.erase(par);
    --deg[par];
    s[par] ^= leaf;
    sit.insert(par);
  }
  cout << edges.size() << endl;
  for (int i = 0; i < edges.size(); ++i)
    cout << edges[i].first << " " << edges[i].second << endl;
  return 0;
}
