#include <bits/stdc++.h>
using namespace std;
template <class IT>
inline void cmax(IT &a, IT b) {
  if (a < b) a = b;
}
template <class IT>
inline void cmin(IT &a, IT b) {
  if (b < a) a = b;
}
template <class IT>
inline bool bmax(IT &a, IT b) {
  if (a < b) {
    a = b;
    return true;
  } else
    return false;
}
template <class IT>
inline bool bmin(IT &a, IT b) {
  if (a > b) {
    a = b;
    return true;
  } else
    return false;
}
const int N = 100005;
pair<int, int> S[N << 4];
vector<int> E[N];
int T, ans;
inline void dfs(int v, int f, int t) {
  int i = E[v].size(), u, c = E[v].size(), b;
  if (f) {
    --c;
    b = min(t + c, T);
  } else
    b = N;
  S[++ans] = make_pair(v, t);
  if (t == b) S[++ans] = make_pair(v, t -= (c + 1));
  while (i--) {
    u = E[v][i];
    if (u != f) {
      dfs(u, v, t + 1);
      S[++ans] = make_pair(v, ++t);
      if (t == b) S[++ans] = make_pair(v, t -= (c + 1));
    }
  }
}
inline void ac() {
  int n, i, v, u;
  cin >> n;
  for (i = (1); i < (n); ++i) {
    cin >> v >> u;
    E[v].push_back(u);
    E[u].push_back(v);
  }
  for (v = (1); v <= (n); ++v) cmax(T, (int)E[v].size());
  dfs(1, 0, 0);
  cout << ans << "\n";
  for (i = (1); i <= (ans); ++i)
    cout << S[i].first << " " << S[i].second << "\n";
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  ac();
  return 0;
}
