#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const int INF = 2e9;
const long long INFLL = 1e18;
const int MAX_N = 100000;
int N;
vector<int> gp[MAX_N + 1];
int sz[MAX_N + 1], D;
int deg[MAX_N + 1];
vector<pair<int, int> > ans;
int p[MAX_N + 1];
int num[MAX_N + 1];
void dfs(int x) {
  deg[x] = (int)gp[x].size();
  for (int i : gp[x]) {
    if (i == p[x]) continue;
    p[i] = x;
    dfs(i);
  }
}
int s[MAX_N + 1], e[MAX_N + 1];
void dfs2(int x) {
  ans.push_back({x, num[x]});
  s[x] = max(1, num[x] - deg[x] + 1);
  e[x] = s[x] + deg[x] - 1;
  for (int i : gp[x]) {
    if (i == p[x]) continue;
    if (num[x] == e[x]) {
      num[x] = s[x] - 1;
      ans.push_back({x, num[x]});
    }
    num[i] = num[x] + 1;
    dfs2(i);
    num[x]++;
    ans.push_back({x, num[x]});
  }
  if (x != 1 && num[x] == e[x]) {
    num[x] = s[x] - 1;
    ans.push_back({x, num[x]});
  }
}
int main() {
  scanf("%d", &N);
  for (int i = 1; i < N; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    gp[a].push_back(b);
    gp[b].push_back(a);
  }
  dfs(1);
  dfs2(1);
  printf("%d\n", (int)ans.size());
  for (int i = 0; i < ans.size(); i++) {
    printf("%d %d\n", ans[i].first, ans[i].second);
  }
  return 0;
}
