#include <bits/stdc++.h>
using namespace std;
int N, T;
vector<pair<int, int> > ans;
set<pair<int, int> > s;
vector<int> ady[200005];
void solve(int x, int t, int p) {
  ans.push_back({x, t});
  int in = t;
  int sons = ady[x].size() - (p != 0);
  for (auto v : ady[x]) {
    if (v == p) continue;
    if (in == T) {
      in = t - sons - 1;
      ans.push_back({x, in});
    }
    in++;
    solve(v, in, x);
    ans.push_back({x, in});
    sons--;
  }
  if (in > t - 1 && x != 1) {
    in = t - 1;
    ans.push_back({x, in});
  }
  return;
}
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cin >> N;
  for (int i = 1; i < N; i++) {
    int u, v;
    cin >> u >> v;
    ady[u].push_back(v);
    ady[v].push_back(u);
  }
  for (int i = 1; i <= N; i++) T = max(T, (int)ady[i].size());
  solve(1, 0, 0);
  for (auto v : ans) s.insert(v);
  if (s.size() != ans.size()) {
    cout << "RIP\n";
  }
  cout << ans.size() << "\n";
  for (auto v : ans) cout << v.first << " " << v.second << "\n";
  return 0;
}
