#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> deg(n), s(n);
  for (int i = 0; i < n; i++) cin >> deg[i] >> s[i];
  vector<pair<int, int>> edges;
  queue<int> q;
  for (int i = 0; i < n; i++)
    if (deg[i] == 1) q.push(i);
  while (!q.empty()) {
    int leaf = q.front();
    q.pop();
    if (deg[leaf] != 1) continue;
    int par = s[leaf];
    edges.push_back({par, leaf});
    deg[par] -= 1;
    s[par] ^= leaf;
    if (deg[par] == 1) q.push(par);
  }
  cout << edges.size() << endl;
  for (auto p : edges) cout << p.first << " " << p.second << '\n';
}
