#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline T read() {
  register T sum = 0;
  register char cc = getchar();
  int sym = 1;
  while (cc != '-' && (cc > '9' || cc < '0')) cc = getchar();
  if (cc == '-') sym = -1, cc = getchar();
  sum = sum * 10 + cc - '0';
  cc = getchar();
  while (cc >= '0' && cc <= '9') sum = sum * 10 + cc - '0', cc = getchar();
  return sym * sum;
}
template <typename T>
inline T read(T& a) {
  a = read<T>();
  return a;
}
template <typename T, typename... Others>
inline void read(T& a, Others&... b) {
  a = read(a);
  read(b...);
}
int n, t, lim;
vector<int> G[100010];
vector<pair<int, int>> ans;
void dfs(int v, int back = 0, int fa = 0) {
  ans.push_back({v, t});
  int cnt = (int)G[v].size() - (fa != 0);
  for (int to : G[v]) {
    if (to == fa) continue;
    if (t == lim) {
      t = back - 1 - cnt;
      ans.push_back({v, t});
    }
    t += 1;
    dfs(to, t, v);
    ans.push_back({v, t});
    cnt -= 1;
  }
  if (fa && t >= back) {
    t = back - 1;
    ans.push_back({v, t});
  }
  t += 1;
}
int main() {
  read(n);
  for (int i = 1; i < n; i++) {
    int x, y;
    read(x, y);
    G[x].push_back(y);
    G[y].push_back(x);
  }
  for (int i = 1; i <= n; i++) lim = max(lim, (int)G[i].size());
  dfs(1);
  printf("%d\n", ans.size());
  for (auto i : ans) printf("%d %d\n", i.first, i.second);
  return 0;
}
