#include <bits/stdc++.h>
using namespace std;
int vis[65540];
vector<int> adj[65540];
vector<pair<int, int> > ed;
int main() {
  int n, deg[65540], s[65540], i;
  cin >> n;
  priority_queue<pair<int, int> > q;
  for (i = 0; i < n; i++) {
    cin >> deg[i] >> s[i];
    if (deg[i] == 1) q.push(make_pair(-deg[i], i));
  }
  while (!q.empty()) {
    pair<int, int> p = q.top();
    q.pop();
    if (vis[p.second] == 2) continue;
    vis[p.second] = 2;
    deg[s[p.second]]--;
    s[s[p.second]] = s[s[p.second]] ^ p.second;
    ed.push_back(make_pair(p.second, s[p.second]));
    if (deg[s[p.second]] == 0) vis[s[p.second]] = 2;
    q.push(make_pair(-deg[s[p.second]], s[p.second]));
  }
  cout << ed.size() << endl;
  for (i = 0; i < ed.size(); i++) {
    cout << ed[i].first << ' ' << ed[i].second << endl;
  }
  return 0;
}
