#include <bits/stdc++.h>
using namespace std;
const int maxn = 100005;
const int maxm = 55;
const int inf = 2147483647;
const long long p = 1000000007;
const double eps = 1e-9;
const long long INF = 9223372036854775807ll;
vector<int> g[maxn];
vector<pair<int, int> > ans;
int deg[maxn], maxd;
int dfs(int u, int f, int d) {
  int rd = d;
  ans.push_back(make_pair(u, d));
  for (register int i = (0); i < (g[u].size()); ++i) {
    int v = g[u][i];
    if (v == f) continue;
    if (d == maxd) {
      d = maxd - deg[u];
      ans.push_back(make_pair(u, d));
    }
    d = dfs(v, u, d + 1) + 1;
    ans.push_back(make_pair(u, d));
  }
  if (u != 1 && d != rd - 1) {
    d = rd - 1;
    ans.push_back(make_pair(u, d));
  }
  return d;
}
int main() {
  int n;
  scanf("%d", &n);
  for (register int i = (0); i < (n - 1); ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    g[u].push_back(v);
    g[v].push_back(u);
    deg[u]++;
    deg[v]++;
    maxd = max(maxd, max(deg[u], deg[v]));
  }
  dfs(1, 0, 0);
  printf("%d\n", (int)ans.size());
  for (register int i = (0); i < (ans.size()); ++i)
    printf("%d %d\n", ans[i].first, ans[i].second);
}
