#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using ll = long long;
using namespace std;
void solve() {
  int n;
  cin >> n;
  queue<int> q;
  int total = 0;
  vector<int> d(n), s(n);
  for (int i = 0; i < n; i++) {
    cin >> d[i] >> s[i];
    total += d[i];
    if (d[i] == 1) q.push(i);
  }
  int ans = total / 2;
  cout << ans << endl;
  while (!q.empty()) {
    int x = q.front();
    q.pop();
    int y = s[x];
    if (d[x] == 0) continue;
    cout << x << " " << y << endl;
    if (--d[y] == 1) q.push(y);
    s[y] = int(s[y] ^ x);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
