#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int d, s;
  int m = n;
  vector<pair<int, int>> v, ans, ans0;
  queue<pair<long long, long long>> leaf;
  int i = 0;
  while (m--) {
    cin >> d >> s;
    v.push_back({d, s});
    if (d == 1) {
      leaf.push({i, s});
    }
    i++;
  }
  while (((int)(leaf).size())) {
    int idx = leaf.front().first;
    int cur = leaf.front().second;
    leaf.pop();
    v[cur].first--;
    v[cur].second ^= idx;
    ans.push_back({cur, idx});
    if (v[cur].first == 1) {
      leaf.push({cur, v[cur].second});
    }
  }
  map<pair<int, int>, int> mp;
  for (auto it : ans) {
    if (!mp[it]) ans0.push_back(it);
    mp[it]++;
    mp[{it.second, it.first}]++;
  }
  cout << ((int)(ans0).size()) << "\n";
  for (auto it : ans0) {
    cout << it.first << " " << it.second << "\n";
  }
}
