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