#include <bits/stdc++.h>
using namespace std;
void test() { cerr << "\n"; }
template <typename T, typename... Args>
void test(T x, Args... args) {
  cerr << "> " << x << " ";
  test(args...);
}
const long long mod = 1e9 + 7;
const int maxn = 1e5 + 9;
const int inf = 0x3f3f3f3f;
long long rd() {
  long long ans = 0;
  char last = ' ', ch = getchar();
  while (!(ch >= '0' && ch <= '9')) last = ch, ch = getchar();
  while (ch >= '0' && ch <= '9') ans = ans * 10 + ch - '0', ch = getchar();
  if (last == '-') ans = -ans;
  return ans;
}
int head[maxn], to[maxn << 1], nex[maxn << 1], now;
void add(int a, int b) {
  nex[++now] = head[a];
  head[a] = now;
  to[now] = b;
}
int deg[maxn];
void init_edge() {
  memset(head, 0, sizeof head);
  now = 0;
}
vector<pair<int, int> > ans;
int mx = -1;
void dfs(int p, int fa, int ti) {
  int tmp = ti;
  ans.push_back({p, ti});
  int son = deg[p];
  if (p != 1) son--;
  for (int i = head[p], u = to[i]; i; i = nex[i], u = to[i]) {
    if (u == fa) continue;
    if (ti == mx) {
      ti -= son + 1;
      ans.push_back({p, ti});
    }
    dfs(u, p, ti + 1);
    ti++;
    ans.push_back({p, ti});
  }
  if (ti != tmp - 1 && fa) ans.push_back({p, tmp - 1});
}
int main() {
  int n = rd();
  for (int i = (int)(1); i <= (int)(n - 1); i++) {
    int a = rd(), b = rd();
    add(a, b);
    add(b, a);
    deg[a]++, deg[b]++;
  }
  for (int i = (int)(1); i <= (int)(n); i++) mx = max(mx, deg[i]);
  dfs(1, 0, 0);
  printf("%d\n", ans.size());
  for (auto P : ans) {
    printf("%d %d\n", P.first, P.second);
  }
  return 0;
}
