#include <bits/stdc++.h>
using namespace std;
int degree[70000], s[70000];
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  int n;
  cin >> n;
  queue<int> Q;
  for (int i = 0; i < n; ++i) {
    cin >> degree[i] >> s[i];
    if (degree[i] == 1) Q.push(i);
  }
  vector<pair<int, int> > edges;
  while (!Q.empty()) {
    int node = Q.front();
    Q.pop();
    if (degree[node] == 0) continue;
    int neighbor = s[node];
    edges.push_back(make_pair(node, neighbor));
    s[neighbor] ^= node;
    --degree[neighbor];
    if (degree[neighbor] == 1) Q.push(neighbor);
  }
  cout << edges.size() << '\n';
  for (int i = 0; i < edges.size(); ++i)
    cout << edges[i].first << ' ' << edges[i].second << '\n';
}
