#include <bits/stdc++.h>
using namespace std;
const int N(1 << 16);
int n;
int d[N], s[N];
set<pair<int, int> > ver;
vector<pair<int, int> > edges;
int main() {
  cin >> n;
  for (int i = 0; i != n; ++i) {
    cin >> d[i] >> s[i];
    ver.insert(make_pair(d[i], i));
  }
  while (!ver.empty()) {
    auto p = *(ver.begin());
    ver.erase(ver.begin());
    if (p.first == 0) continue;
    int x = s[p.second];
    edges.push_back(make_pair(p.second, x));
    ver.erase(make_pair(d[x], x));
    s[x] ^= p.second;
    ver.insert(make_pair(--d[x], x));
  }
  cout << edges.size() << endl;
  for (int i = 0; i != edges.size(); ++i)
    cout << edges[i].first << " " << edges[i].second << endl;
  return 0;
}
