#include <bits/stdc++.h>
using namespace std;
const double PI = 3.14159265359;
const double EPS = 1e-6;
const long long INF = ((long long)1 << 62);
const long long P = 1e9 + 7;
struct node {
  int deg;
  int s;
  int cv;
  vector<int> adj;
};
int seen[1 << 20];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  vector<node> nodes(n);
  int deg, s;
  priority_queue<pair<int, int> > by_deg;
  for (int i = 0; i < n; i++) {
    cin >> deg >> s;
    nodes[i].deg = deg;
    nodes[i].s = s;
    nodes[i].cv = 0;
    by_deg.push(make_pair(-deg, i));
  }
  while (!by_deg.empty()) {
    pair<int, int> top = by_deg.top();
    by_deg.pop();
    int curr = top.second;
    if (seen[curr]) continue;
    if ((int)nodes[curr].adj.size() == nodes[curr].deg) {
      seen[curr] = 1;
    } else {
      int left = nodes[curr].cv ^ nodes[curr].s;
      nodes[curr].cv = nodes[curr].s;
      nodes[curr].adj.push_back(left);
      nodes[left].adj.push_back(curr);
      nodes[left].cv = nodes[left].cv ^ curr;
      by_deg.push(
          make_pair(-(nodes[curr].deg - (int)nodes[curr].adj.size()), curr));
      by_deg.push(
          make_pair(-(nodes[left].deg - (int)nodes[left].adj.size()), left));
    }
  }
  set<pair<int, int> > res;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < nodes[i].adj.size(); j++) {
      int curr = i;
      int next = nodes[i].adj[j];
      if (curr > next) swap(curr, next);
      res.insert(make_pair(curr, next));
    }
  }
  cout << res.size() << endl;
  for (pair<int, int> x : res) {
    cout << x.first << " " << x.second << endl;
  }
  return 0;
}
