#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long mod1 = 998244353;
const long long inf = 9223372036854775807ll;
vector<long long> sum, degree, xr;
vector<pair<long long, long long> > edges;
void solve() {
  long long n;
  cin >> n;
  sum = vector<long long>(n);
  xr = vector<long long>(n);
  degree = vector<long long>(n);
  long long mn = inf;
  for (long long i = (0); i < (n); i++) {
    sum[i] = 0;
    long long d, s;
    cin >> d >> s;
    xr[i] = s;
    degree[i] = d;
    if (d != 0) mn = min(d, mn);
  }
  if (mn == inf) {
    cout << 0;
    return;
  }
  priority_queue<pair<long long, long long> > q;
  for (long long i = (0); i < (n); i++) {
    if (mn == degree[i]) q.push({-degree[i], i});
  }
  while (!q.empty()) {
    long long now = q.top().second;
    q.pop();
    cerr << now << '\n';
    if (degree[now] == 0) continue;
    long long partner = sum[now] ^ xr[now];
    degree[partner]--;
    degree[now]--;
    sum[now] ^= partner;
    sum[partner] ^= now;
    edges.push_back({now, partner});
    q.push({-degree[partner], partner});
  }
  cout << edges.size() << '\n';
  for (long long i = (0); i < (edges.size()); i++)
    cout << edges[i].first << " " << edges[i].second << '\n';
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  solve();
  return 0;
}
