#include <bits/stdc++.h>
using namespace std;
struct Edge {
  int v, nxt;
} e[200010];
int tot;
int first[100010], deg[100010];
void build(int u, int v) {
  e[++tot] = (Edge){v, first[u]};
  first[u] = tot;
  deg[u]++;
  return;
}
int res[1000010];
int p[1000010], t[1000010];
int num;
int m;
void add(int x, int y) {
  num++;
  p[num] = x;
  t[num] = y;
}
void dfs(int u, int lst, int now) {
  add(u, now);
  int T = now;
  int cnt = deg[u] - 1;
  for (int i = first[u]; i; i = e[i].nxt)
    if (e[i].v != lst) {
      if (T == m) {
        T = now - 1 - cnt;
        add(u, T);
      }
      cnt--;
      dfs(e[i].v, u, T + 1);
      add(u, ++T);
    }
  if (lst && T != now - 1) add(u, now - 1);
  return;
}
int main() {
  int n;
  scanf("%d", &n);
  if (n == 1) {
    printf("1\n1 0\n");
    return 0;
  }
  for (int i = 1; i < n; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    build(u, v);
    build(v, u);
  }
  for (int i = 1; i <= n; i++) m = max(m, deg[i]);
  dfs(1, 0, 0);
  printf("%d\n", num);
  for (int i = 1; i <= num; i++) printf("%d %d\n", p[i], t[i]);
  return 0;
}
