#include <bits/stdc++.h>
using namespace std;
inline int read() {
  char ch = getchar();
  int nega = 1;
  while (!isdigit(ch)) {
    if (ch == '-') nega = -1;
    ch = getchar();
  }
  int ans = 0;
  while (isdigit(ch)) {
    ans = ans * 10 + ch - 48;
    ch = getchar();
  }
  if (nega == -1) return -ans;
  return ans;
}
inline int min(int x, int y, int z) { return min(x, min(y, z)); }
inline int max(int x, int y, int z) { return max(x, max(y, z)); }
inline int add(int x, int y) {
  return x + y >= 998244353 ? x + y - 998244353 : x + y;
}
inline int add(int x, int y, int z) { return add(add(x, y), z); }
inline int sub(int x, int y) { return x - y < 0 ? x - y + 998244353 : x - y; }
inline int mul(int x, int y) { return 1LL * x * y % 998244353; }
inline int mul(int x, int y, int z) { return mul(mul(x, y), z); }
vector<int> G[100005];
int maxn;
vector<pair<int, int> > ans;
void dfs(int u, int fa, int t) {
  ans.push_back(make_pair(u, t));
  int x = t;
  for (int v : G[u]) {
    if (v == fa) continue;
    if (t == maxn) t = maxn - G[u].size(), ans.push_back(make_pair(u, t));
    dfs(v, u, t + 1);
    t++;
    ans.push_back(make_pair(u, t));
  }
  if (fa != 0 && t != x - 1) ans.push_back(make_pair(u, x - 1));
}
signed main() {
  int n = read();
  for (int i = 1; i < n; i++) {
    int u = read(), v = read();
    G[u].push_back(v), G[v].push_back(u);
  }
  for (int i = 1; i <= n; i++)
    if ((int)G[i].size() > maxn) maxn = G[i].size();
  dfs(1, 0, 0);
  cout << ans.size() << endl;
  for (pair<int, int> i : ans) printf("%d %d\n", i.first, i.second);
  return 0;
}
