#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T sqr(const T& a) {
  return a * a;
}
const long double EPS = 1e-9;
const long double PI = 2 * acos(0.0);
const int N = 100000;
int counts[N];
int xors[N];
vector<int> g[N];
queue<int> qq;
vector<pair<int, int> > ans;
inline void Add(int x, int y) {
  ans.push_back({x, y});
  g[x].push_back(y);
  g[y].push_back(x);
  if (int(g[x].size()) + 1 == counts[x]) qq.push(x);
  if (int(g[y].size()) + 1 == counts[y]) qq.push(y);
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d%d", &counts[i], &xors[i]);
    if (counts[i] == 1) qq.push(i);
  }
  while (!qq.empty()) {
    int x = qq.front();
    qq.pop();
    assert(counts[x] >= int(g[x].size()));
    if (counts[x] != 1 + int(g[x].size())) continue;
    int s = 0;
    for (int to : g[x]) {
      s ^= to;
    }
    Add(x, xors[x] ^ s);
  }
  printf("%d\n", int(ans.size()));
  for (pair<int, int>& p : ans) printf("%d %d\n", p.first, p.second);
  return 0;
}
