#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a * (b / gcd(a, b)); }
long long Max(long long a, long long b) { return a > b ? a : b; }
long long Min(long long a, long long b) { return a < b ? a : b; }
long long power(long long x, long long y, long long p) {
  long long res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = ((res % p) * (x % p)) % p;
    y = y >> 1;
    x = ((x % p) * (x % p)) % p;
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, s, degree, x, y, in, z;
  cin >> n;
  queue<long long> q;
  vector<pair<long long, long long> > arr, ans;
  for (long long i = 0; i < n; i++) {
    cin >> degree >> s;
    arr.push_back(make_pair(degree, s));
    if (degree == 1) {
      q.push(i);
    }
  }
  while (q.empty() != true) {
    if (arr[q.front()].first == 1) {
      if (q.front() != arr[q.front()].second)
        ans.push_back(make_pair(q.front(), arr[q.front()].second));
      arr[q.front()].first = 0;
      z = arr[q.front()].second;
      arr[q.front()].second = 0;
      arr[z].second ^= q.front();
      arr[z].first -= 1;
      if (arr[z].first == 1) {
        q.push(z);
      }
    }
    q.pop();
  }
  cout << ans.size() << endl;
  for (long long i = 0; i < ans.size(); i++) {
    cout << ans[i].first << " " << ans[i].second << endl;
  }
  return 0;
}
