#include <bits/stdc++.h>
using namespace std;
void Weapons19() {
  cin.sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}
int32_t main() {
  Weapons19();
  long long n;
  cin >> n;
  priority_queue<pair<long long, pair<long long, long long>>,
                 vector<pair<long long, pair<long long, long long>>>,
                 greater<pair<long long, pair<long long, long long>>>>
      q;
  vector<long long> f(n), s(n);
  for (long long i = 0; i < n; i++) {
    long long a, b;
    cin >> a >> b;
    f[i] = a;
    s[i] = b;
    if (a == 1) q.push({a, {b, i}});
  }
  vector<long long> vis(n);
  vector<long long> xr(n);
  vector<pair<long long, long long>> ans;
  while (!q.empty()) {
    pair<long long, pair<long long, long long>> k = q.top();
    q.pop();
    if (f[k.second.second] == 0) continue;
    long long r = xr[k.second.second] ^ k.second.first;
    if (r != k.second.second && f[r] > 0)
      ans.push_back({r, k.second.second});
    else
      continue;
    xr[r] = xr[r] ^ k.second.second;
    xr[k.second.second] = xr[k.second.second] ^ r;
    f[r]--;
    f[k.second.second]--;
    if (f[r] == 1) q.push({f[r], {s[r], r}});
  }
  cout << ans.size() << "\n";
  for (auto a : ans) cout << a.first << " " << a.second << "\n";
}
