#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
struct edge {
  int y, nex;
} s[N << 1];
int first[N], len = 0, n, d[N], p;
vector<pair<int, int> > V;
void ins(int x, int y) {
  s[++len] = (edge){y, first[x]};
  first[x] = len;
  d[x]++;
}
void dfs(int x, int fa, int t) {
  int las = t;
  V.push_back(make_pair(x, t));
  int op = 0;
  if (d[x] <= t)
    V.push_back(make_pair(x, t - d[x])), t = t - d[x];
  else
    op = d[x];
  for (int i = first[x]; i != 0; i = s[i].nex)
    if (s[i].y != fa) {
      t++;
      dfs(s[i].y, x, t);
      V.push_back(make_pair(x, t));
      if (op && t == op) V.push_back(make_pair(x, 0)), t = 0;
    }
}
int main() {
  scanf("%d", &n);
  int x, y;
  for (int i = 1; i < n; i++) scanf("%d %d", &x, &y), ins(x, y), ins(y, x);
  for (int i = 1; i <= n; i++) p = max(p, d[i]);
  int t = 0;
  V.push_back(make_pair(1, 0));
  for (int i = first[1]; i != 0; i = s[i].nex) {
    t++;
    dfs(s[i].y, 1, t);
    V.push_back(make_pair(1, t));
  }
  printf("%d\n", V.size());
  for (int i = 0; i < V.size(); i++) printf("%d %d\n", V[i].first, V[i].second);
}
