#include <bits/stdc++.h>
using namespace std;
int vis[(1 << 16) + 10], degree[(1 << 16) + 10], val[(1 << 16) + 10];
vector<pair<int, int> > ans;
priority_queue<pair<pair<int, int>, int>, vector<pair<pair<int, int>, int> >,
               greater<pair<pair<int, int>, int> > >
    q;
int main() {
  int n;
  scanf("%d", &n);
  int deg, s;
  for (int i = 0; i < n; i++) {
    scanf("%d %d", &deg, &s);
    degree[i] = deg;
    val[i] = s;
    q.push(make_pair(make_pair(deg, s), i));
  }
  while (!q.empty()) {
    pair<pair<int, int>, int> temp = q.top();
    q.pop();
    if (vis[temp.second] || degree[temp.second] == 0) continue;
    if (temp.first.first == 1) {
      ans.push_back(make_pair(temp.second, temp.first.second));
      degree[temp.first.second] -= 1;
      int degr = degree[temp.first.second];
      val[temp.first.second] ^= temp.second;
      int vall = val[temp.first.second];
      q.push(make_pair(make_pair(degr, vall), temp.first.second));
      vis[temp.second] = 1;
    } else if (temp.first.first == 0)
      vis[temp.second] = 1;
  }
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i].first << " " << ans[i].second << endl;
  }
  return 0;
}
