#include <bits/stdc++.h>
using namespace std;
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
int dy[] = {1, 0, -1, 0, 1, -1, 1, -1};
long long fix_mod(long long x, long long y) { return (y + x % y) % y; }
void fast() {
  std::ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
}
pair<int, int> arr[(int)1e6 + 10];
int main() {
  fast();
  int n;
  int d, x;
  cin >> n;
  set<pair<pair<int, int>, int>> s;
  for (int i = 0; i < n; i++) {
    cin >> d >> x;
    s.insert({{d, x}, i});
    arr[i] = {d, x};
  }
  vector<pair<int, int>> v;
  while (!s.empty()) {
    pair<pair<int, int>, int> t = *s.begin();
    s.erase(s.begin());
    if (t.first.first == 0) continue;
    v.push_back({t.second, t.first.second});
    auto idx = s.lower_bound(
        pair<pair<int, int>, int>{arr[t.first.second], t.first.second});
    int y = idx->second;
    s.erase(idx);
    arr[y].first--;
    arr[y].second ^= t.second;
    s.insert({arr[y], y});
  }
  cout << v.size() << "\n";
  for (auto c : v) cout << c.first << " " << c.second << "\n";
}
