#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1 << 17;
pair<int, int> v[MAXN];
set<pair<int, int> > ans;
queue<int> Q;
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> v[i].first >> v[i].second;
    if (v[i].first == 1) Q.push(i);
  }
  while (!Q.empty()) {
    int k = Q.front();
    Q.pop();
    if (v[k].first == 0) continue;
    int id = v[k].second;
    v[id].first--, v[id].second ^= k;
    ans.insert(make_pair(k, id));
    if (v[id].first == 1) Q.push(id);
  }
  cout << ans.size() << endl;
  for (auto it = ans.begin(); it != ans.end(); it++) {
    pair<int, int> a = *it;
    cout << a.first << " " << a.second << endl;
  }
  return 0;
}
