#include <bits/stdc++.h>
int read() {
  static int c, x;
  while ((c = getchar()) < 48) {
  }
  x = c & 15;
  while ((c = getchar()) >= 48) x = x * 10 + (c & 15);
  return x;
}
struct edge {
  int next, to;
} e[100010 << 1];
int mx, ans;
int deg[100010], head[100010];
int ax[100010 << 2], ay[100010 << 2];
inline void add(const int &x, const int &y) {
  static int ei;
  e[++ei].next = head[x];
  e[ei].to = y;
  head[x] = ei;
  ++deg[x];
}
inline void append(const int &x, const int &y) {
  if (ax[ans] != x || ay[ans] != y) {
    ++ans;
    ax[ans] = x;
    ay[ans] = y;
  }
}
void dfs(const int &x, int t, const int &fa) {
  append(x, t);
  for (int i = head[x]; i; i = e[i].next) {
    const int y = e[i].to;
    if (y != fa) {
      if (t == mx) {
        t -= deg[x];
        append(x, t);
      }
      dfs(y, t + 1, x);
      append(y, t);
      append(x, t + 1);
      ++t;
    }
  }
}
int main() {
  const int n = read();
  for (int i = n; --i;) {
    const int x = read(), y = read();
    add(x, y);
    add(y, x);
  }
  for (int i = 1; i <= n; ++i) {
    if (mx < deg[i]) mx = deg[i];
  }
  dfs(1, 0, 0);
  printf("%d\n", ans);
  for (int i = 1; i <= ans; ++i) {
    printf("%d %d\n", ax[i], ay[i]);
  }
  return 0;
}
