#include <bits/stdc++.h>
using namespace std;
const int maxn = 70000;
struct Node {
  int v, cnt, sum;
  Node(int vv = 0, int a = 0, int b = 0) : v(vv), cnt(a), sum(b) {}
  bool operator<(const Node &rhs) const { return cnt < rhs.cnt; }
};
set<pair<int, int> > edge;
int main() {
  int n;
  scanf("%d", &n);
  vector<Node> vec;
  stack<int> sk;
  for (int i = 0; i < n; ++i) {
    int a, b;
    scanf("%d%d", &a, &b);
    vec.push_back(Node(i, a, b));
    if (a == 1) sk.push(i);
  }
  while (!sk.empty()) {
    int p = sk.top();
    sk.pop();
    if (vec[p].cnt != 1) continue;
    int a = max(vec[p].v, vec[p].sum), b = min(vec[p].v, vec[p].sum);
    if (a != b) edge.insert(make_pair(a, b));
    int to = vec[p].sum;
    vec[to].cnt--;
    vec[to].sum ^= vec[p].v;
    if (vec[to].cnt == 1) sk.push(to);
  }
  printf("%d\n", edge.size());
  for (set<pair<int, int> >::iterator it = edge.begin(); it != edge.end();
       ++it) {
    pair<int, int> p = *it;
    printf("%d %d\n", p.first, p.second);
  }
  return 0;
}
