#include <bits/stdc++.h>
using namespace std;
const int N = (1 << 16) + 5;
vector<int> adj[N];
set<pair<int, int> > s;
int xr[N], dg[N];
int n;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> dg[i] >> xr[i];
    if (dg[i] == 0) continue;
    s.insert(make_pair(dg[i], i));
  }
  while (!s.empty()) {
    pair<int, int> x = *s.begin();
    int u = x.second;
    int v = xr[u];
    dg[v]--;
    xr[v] = xr[v] ^ u;
    adj[u].push_back(v);
    s.erase(x);
    x = *s.lower_bound(make_pair(dg[v] + 1, v));
    s.erase(x);
    if (dg[v] == 0) continue;
    s.insert(make_pair(dg[v], v));
  }
  vector<pair<int, int> > ans;
  for (int i = 0; i < n; i++) {
    int x = adj[i].size();
    for (int j = 0; j < x; j++) {
      ans.push_back(make_pair(adj[i][j], i));
    }
  }
  n = ans.size();
  cout << n << endl;
  for (int i = 0; i < n; i++) {
    cout << ans[i].first << " " << ans[i].second << endl;
  }
}
