#include <bits/stdc++.h>
using namespace std;
int n;
queue<pair<int, int> > q;
vector<pair<int, int> > v;
vector<vector<int> > g;
set<pair<int, int> > out;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    v.push_back({x, y});
    if (x == 1) q.push({i, y});
  }
  while (!q.empty()) {
    pair<int, int> x = q.front();
    q.pop();
    int y = x.second;
    v[y].second ^= x.first;
    v[y].first--;
    out.insert({min(x.first, y), max(x.first, y)});
    if (v[y].first == 1) {
      q.push({y, v[y].second});
    }
  }
  cout << out.size() << "\n";
  for (auto a : out) {
    cout << a.first << " " << a.second << "\n";
  }
  return 0;
}
