#include <bits/stdc++.h>
using namespace std;
int deg[100000], xorsum[100000];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  vector<vector<int>> adj(n, vector<int>());
  queue<int> q;
  for (int i = 0; i < n; i++) {
    cin >> deg[i] >> xorsum[i];
    if (deg[i] == 1) q.push(i);
  }
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    if (deg[u] == 1) {
      int xr = 0;
      for (int v : adj[u]) xr ^= v;
      int par = xorsum[u] ^ xr;
      adj[u].push_back(par);
      adj[par].push_back(u);
      deg[par]--;
      if (deg[par] <= 1) q.push(par);
    }
  }
  int nedges = 0;
  for (int u = 0; u < n; u++) nedges += adj[u].size();
  cout << nedges / 2 << '\n';
  for (int u = 0; u < n; u++) {
    for (int v : adj[u])
      if (v > u) cout << u << " " << v << '\n';
  }
}
