#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > ans;
vector<int> e[100010];
void dfs(int x, int p, int entry) {
  ans.emplace_back(x, entry);
  if (x == 1) {
    for (int it : e[x])
      if (it != p) dfs(it, x, ++entry), ans.emplace_back(1, entry);
  } else {
    int cur = entry;
    int sz = e[x].size() - 1;
    if (entry - 1 >= sz) {
      cur = entry - 1 - sz;
      ans.emplace_back(x, cur);
      for (int it : e[x])
        if (it != p) {
          cur++;
          dfs(it, x, cur), ans.emplace_back(x, cur);
        }
    } else {
      for (int it : e[x])
        if (it != p) {
          ++cur;
          dfs(it, x, cur), ans.emplace_back(x, cur);
          if (cur == sz + 1) {
            cur = 0;
            ans.emplace_back(x, 0);
          }
        }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 1, u, v; i < n; i++) {
    cin >> u >> v;
    e[u].emplace_back(v);
    e[v].emplace_back(u);
  }
  dfs(1, 0, 0);
  cout << ans.size() << '\n';
  for (auto &[u, v] : ans) cout << u << ' ' << v << '\n';
}
