#include <bits/stdc++.h>
using namespace std;
const int maxn = (1 << 17) + 10;
int main() {
  int n;
  vector<pair<int, int> > a;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int t1, t2;
    scanf("%d%d", &t1, &t2);
    a.emplace_back(t1, t2);
  }
  queue<pair<int, int> > q;
  queue<int> fr;
  vector<pair<int, int> > res;
  for (int i = 0; i < a.size(); i++) {
    if (a[i].first == 1) q.push(a[i]), fr.push(i);
  }
  while (!q.empty()) {
    auto cur = q.front();
    int from = fr.front();
    q.pop(), fr.pop();
    if (a[from].first > 0) {
      res.emplace_back(from, cur.second);
      a[from].first--;
      a[cur.second].first--;
      a[cur.second].second ^= from;
      if (a[cur.second].first == 1) {
        q.push(a[cur.second]), fr.push(cur.second);
      }
    }
  }
  cout << res.size() << endl;
  for (auto it : res) {
    printf("%d %d\n", it.first, it.second);
  }
  return 0;
}
