#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
vector<int> v[N];
vector<pair<int, int> > ans;
int deg[N], maxT;
void dfs(int x, int T, int u) {
  ans.push_back({x, T});
  int beginT = T;
  for (auto it : v[x])
    if (it != u) {
      if (T == maxT) {
        T = maxT - deg[x];
        ans.push_back({x, T});
      }
      dfs(it, T + 1, x);
      ans.push_back({x, ++T});
    }
  if (T >= beginT) ans.push_back({x, beginT - 1});
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i < n; i++) {
    int x, y;
    cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x);
    deg[x]++;
    deg[y]++;
  }
  for (int i = 1; i <= n; i++) maxT = max(maxT, deg[i]);
  dfs(1, 0, 0);
  ans.pop_back();
  cout << ans.size() << "\n";
  for (auto it : ans) cout << it.first << " " << it.second << "\n";
}
