#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const int mo = 1000000007;
inline void gn(long long &x) {
  int sg = 1;
  char c;
  while (((c = getchar()) < '0' || c > '9') && c != '-')
    ;
  c == '-' ? (sg = -1, x = 0) : (x = c - '0');
  while ((c = getchar()) >= '0' && c <= '9') x = x * 10 + c - '0';
  x *= sg;
}
inline void gn(int &x) {
  long long t;
  gn(t);
  x = t;
}
inline void gn(unsigned long long &x) {
  long long t;
  gn(t);
  x = t;
}
inline void gn(double &x) {
  double t;
  scanf("%lf", &t);
  x = t;
}
inline void gn(long double &x) {
  double t;
  scanf("%lf", &t);
  x = t;
}
template <class T1, class T2>
inline void gn(T1 &r, T2 &s) {
  gn(r), gn(s);
}
template <class T1, class T2, class T3>
inline void gn(T1 &r, T2 &s, T3 &t) {
  gn(r), gn(s), gn(t);
}
template <class T1, class T2, class T3, class T4>
inline void gn(T1 &r, T2 &s, T3 &t, T4 &u) {
  gn(r), gn(s), gn(t), gn(u);
}
inline void gs(char *s) { scanf("%s", s); }
inline void gc(char &c) {
  while ((c = getchar()) > 126 || c < 33)
    ;
}
inline void pc(char c) { putchar(c); }
const int DX[] = {1, 0, -1, 0}, DY[] = {0, 1, 0, -1};
long long powmod(long long a, long long b) {
  long long res = 1;
  a %= mo;
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % mo;
    a = a * a % mo;
  }
  return res;
}
long long powmod(long long a, long long b, long long mo) {
  long long res = 1;
  a %= mo;
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % mo;
    a = a * a % mo;
  }
  return res;
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
const int N = 211111, M = 111111;
int l, m, n, t, C, x, y;
vector<int> a[N];
int mx;
map<pair<int, int>, pair<int, int> > nxt;
vector<pair<int, int> > ans;
int cnt = 0;
void dfs(int x, int f, int t) {
  int T = t;
  int ok = t == 0;
  for (auto i : a[x])
    if (i != f) {
      if (t == mx) {
        t -= ((int)(a[x]).size());
        nxt[make_pair(x, mx)] = make_pair(x, t);
        ++cnt;
        ok = 1;
      }
      dfs(i, x, t + 1);
      nxt[make_pair(x, t)] = make_pair(i, t + 1);
      ++cnt;
      nxt[make_pair(i, t)] = make_pair(x, t + 1);
      ++cnt;
      ++t;
    }
  if (!ok) {
    nxt[make_pair(x, t)] = make_pair(x, T - 1);
    ++cnt;
  }
}
int main() {
  scanf("%d", &n);
  for (int i = (2); i <= (n); ++i)
    scanf("%d%d", &x, &y), a[x].push_back(y), a[y].push_back(x);
  if (n == 1) {
    printf("1\n1 0\n");
    return 0;
  }
  for (int i = (1); i <= (n); ++i) mx = max(mx, ((int)(a[i]).size()));
  dfs(1, 0, 0);
  for (pair<int, int> q = make_pair(1, 0);; q = nxt[q]) {
    ans.push_back(q);
    if (--cnt == -1) break;
  }
  printf("%d\n", ((int)(ans).size()));
  for (auto i : ans) printf("%d %d\n", i.first, i.second);
  return 0;
}
