#include <bits/stdc++.h>
using namespace std;
const long long int N = 1e6 + 5;
const long long int mod = 1e9 + 7;
long long int dx[] = {1, -1, 0, 0};
long long int dy[] = {0, 0, 1, -1};
long long int xor_arr[N];
long long int cnt[N];
vector<pair<long long int, long long int> > ans;
int main() {
  ios::sync_with_stdio(false);
  long long int n;
  cin >> n;
  queue<pair<long long int, long long int> > q;
  for (long long int i = 1; i < n + 1; i++) {
    long long int x, y;
    cin >> x >> y;
    cnt[i - 1] = x;
    xor_arr[i - 1] = y;
    if (x == 1) q.push(make_pair(y, i - 1));
  }
  while (!q.empty()) {
    pair<long long int, long long int> temp = q.front();
    q.pop();
    long long int xo = temp.first;
    long long int ind = temp.second;
    if (cnt[ind] == 0) {
      continue;
    }
    cnt[ind]--;
    long long int to = xo;
    ans.push_back(make_pair(ind, to));
    cnt[to]--;
    xor_arr[to] ^= ind;
    xor_arr[ind] = 0;
    if (cnt[to] == 1) {
      q.push(make_pair(xor_arr[to], to));
    }
  }
  cout << ans.size() << endl;
  for (long long int i = 0; i < ans.size(); i++) {
    cout << ans[i].first << " " << ans[i].second << endl;
  }
  return 0;
}
