#include <bits/stdc++.h>
using namespace std;
long long power(long long a, long long b) {
  long long ans = 1;
  while (b > 0) {
    if (b % 2 != 0) {
      ans = (ans * a) % 1000000007;
    }
    a = (a * a) % 1000000007;
    b >>= 1;
  }
  return ans;
}
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int t = 1;
  while (t--) {
    int n;
    cin >> n;
    int deg[n];
    memset(deg, 0, sizeof(deg));
    int xo[n];
    int a, b;
    vector<pair<int, int>> v;
    queue<int> q;
    for (int i = 0; i < n; i++) {
      cin >> deg[i] >> xo[i];
      if (deg[i] == 1) q.push(i);
    }
    while (q.empty() == false) {
      int z = q.front();
      q.pop();
      deg[z]--;
      if (deg[xo[z]] == 0 || deg[z] < 0) continue;
      deg[xo[z]]--;
      xo[xo[z]] = xo[xo[z]] ^ z;
      if (deg[xo[z]] == 1) {
        q.push(xo[z]);
      }
      v.push_back({z, xo[z]});
    }
    cout << v.size() << endl;
    for (int i = 0; i < v.size(); i++)
      cout << v[i].first << " " << v[i].second << endl;
  }
  return 0;
}
