#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 7;
vector<int> G[maxn];
vector<pair<int, int> > ans;
int mx;
void dfs(int u, int fa, int t) {
  int ct = t - 1;
  ans.push_back({u, t});
  int num = mx - G[u].size();
  for (int i = 0; i < G[u].size(); i++) {
    int v = G[u][i];
    if (v == fa) continue;
    if (t == mx) {
      t = num;
      ans.push_back({u, t});
    }
    t++;
    dfs(v, u, t);
    ans.push_back({u, t});
  }
  if (u != 1 && t != ct) {
    ans.push_back({u, ct});
  }
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    G[x].push_back(y);
    G[y].push_back(x);
    mx = max(mx, (int)max(G[x].size(), G[y].size()));
  }
  dfs(1, -1, 0);
  printf("%d\n", ans.size());
  for (int i = 0; i < ans.size(); i++) {
    printf("%d %d\n", ans[i].first, ans[i].second);
  }
  return 0;
}
