Let's define a forest as a non-directed acyclic graph (also without loops and parallel edges). One day Misha played with the forest consisting of n vertices. For each vertex v from 0 to n - 1 he wrote down two integers, degreev and sv, were the first integer is the number of vertices adjacent to vertex v, and the second integer is the XOR sum of the numbers of vertices adjacent to v (if there were no adjacent vertices, he wrote down 0). 

Next day Misha couldn't remember what graph he initially had. Misha has values degreev and sv left, though. Help him find the number of edges and the edges of the initial graph. It is guaranteed that there exists a forest that corresponds to the numbers written by Misha.

Input

The first line contains integer n (1 ≤ n ≤ 216), the number of vertices in the graph.

The i-th of the next lines contains numbers degreei and si (0 ≤ degreei ≤ n - 1, 0 ≤ si < 216), separated by a space.

Output

In the first line print number m, the number of edges of the graph.

Next print m lines, each containing two distinct numbers, a and b (0 ≤ a ≤ n - 1, 0 ≤ b ≤ n - 1), corresponding to edge (a, b).

Edges can be printed in any order; vertices of the edge can also be printed in any order.

Examples

Input

3
2 3
1 0
1 0


Output

2
1 0
2 0


Input

2
1 1
1 0


Output

1
0 1

Note

The XOR sum of numbers is the result of bitwise adding numbers modulo 2. This operation exists in many modern programming languages. For example, in languages C++, Java and Python it is represented as "^", and in Pascal — as "xor".
#include <bits/stdc++.h>
using namespace std;
const int int_inf = 0x3f3f3f3f;
const long long ll_inf = 0x3f3f3f3f3f3f3f3fll;
const double pi = acos(-1.0);
const double eps = 1e-8;
template <class T>
inline T abs(const T first) {
  return first < 0 ? -first : first;
}
template <class T>
inline void get_min(T &a, T b) {
  if (a > b) a = b;
}
template <class T>
inline void get_max(T &a, T b) {
  if (a < b) a = b;
}
template <class T>
inline void fix(T &a, T mo) {
  while (a >= mo) a -= mo;
  while (a < 0) a += mo;
}
template <class T>
inline void inc(T &a, T b, T mo) {
  a += b;
  fix(a, mo);
}
template <class T>
inline void dec(T &a, T b, T mo) {
  a -= b;
  fix(a, mo);
}
template <class T>
inline T mul_mod(T a, T b, T mo) {
  T ans = 0;
  for (; b; b >>= 1) {
    if (b & 1) inc(ans, a, mo);
    inc(a, a, mo);
  }
  return ans;
}
template <class T>
inline T pow_mod(T a, T b, T mo) {
  T ans = 1;
  for (; b; b >>= 1) {
    if (b & 1) ans = (long long)ans * a % mo;
    a = (long long)a * a % mo;
  }
  return ans;
}
template <class T>
inline T big_pow_mod(T a, T b, T mo) {
  T ans = 1;
  for (; b; b >>= 1) {
    if (b & 1) ans = mul_mod(ans, a, mo);
    a = mul_mod(a, a, mo);
  }
  return ans;
}
template <class T>
inline T pow(T a, T b) {
  T ans = 1;
  for (; b; b >>= 1) {
    if (b & 1) ans *= a;
    a *= a;
  }
  return ans;
}
template <class T>
inline T sqr(T first) {
  return first * first;
}
template <class T>
inline int sgn(T first) {
  if (first > eps) return 1;
  if (first < -eps) return -1;
  return 0;
}
template <class T>
inline void read_int(T &first) {
  first = 0;
  char ch;
  bool flag = 0;
  while (ch = getchar(), !isdigit(ch) && ch != '-')
    ;
  if (ch == '-')
    flag = 1;
  else
    first = ch - '0';
  while (ch = getchar(), isdigit(ch))
    first = (first << 3) + first + first + ch - '0';
  if (flag) first = -first;
}
template <class T>
inline void read_float(T &first) {
  first = 0;
  long double now_pos = 0.1;
  char ch;
  while (ch = getchar(), !isdigit(ch) && ch != '-')
    ;
  bool flag = 0, decimal = 0;
  if (ch == '-')
    flag = 1;
  else if (ch == '.')
    decimal = 1;
  while (ch = getchar(), isdigit(ch) || ch == '.') {
    if (ch == '.')
      decimal = 1;
    else if (decimal) {
      first += now_pos * (ch - '0');
      now_pos *= 0.1;
    } else
      first = first * 10 + ch - '0';
  }
  if (flag) first = -first;
}
template <class T>
class Queue {
 private:
  vector<T> q;
  int op, cls;
  int size;

 public:
  inline Queue(int sz) {
    size = sz;
    q.clear();
    q.resize(size);
    op = 0, cls = 0;
  }
  inline void clear() { op = 0, cls = 0; }
  inline void push_back(T first) {
    cls++;
    if (cls == size) cls = 0;
    q[cls] = first;
  }
  inline void push_front(T first) {
    q[op] = first;
    op--;
    if (op < 0) op = size - 1;
  }
  inline void pop_front() {
    op++;
    if (op == size) op = 0;
  }
  inline void pop_back() {
    cls--;
    if (cls < 0) cls = size - 1;
  }
  inline T front() {
    int now = op + 1;
    if (now == size) now = 0;
    return q[now];
  }
  inline T back() { return q[cls]; }
  inline bool empty() { return op == cls; }
};
int d[100010], s[100010];
int a[100010];
int from[100010], to[100010];
int main() {
  int n;
  int m = 0;
  read_int(n);
  for (int i = 0; i < n; i++) {
    read_int(d[i]);
    read_int(s[i]);
  }
  queue<int> q;
  for (int i = 0; i < n; i++)
    if (d[i] == 1) q.push(i);
  while (!q.empty()) {
    int now = q.front();
    q.pop();
    if (!d[now]) continue;
    int t = s[now];
    from[++m] = now;
    to[m] = t;
    s[t] ^= now;
    d[t]--;
    if (d[t] == 1) q.push(t);
  }
  printf("%d\n", m);
  for (int i = 1; i <= m; i++) printf("%d %d\n", from[i], to[i]);
  return 0;
}
