#include <bits/stdc++.h>
using namespace std;
int n;
vector<vector<int>> g(1e5 + 1);
vector<pair<int, int>> ans;
void dfs(const int& v, const int& par, int timenow) {
  int val = timenow - 1;
  if (par == -1) {
    ans.push_back({v, timenow});
    for (int i = 0; i < g[v].size(); i++) {
      dfs(g[v][i], v, timenow + 1);
      ++timenow;
      ans.push_back({v, timenow});
    }
    return;
  }
  int can = val;
  int need = g[v].size() - 1 - can;
  ans.push_back({v, timenow});
  bool b = false;
  for (int i = 0, count = 0; i < g[v].size() && count < need; i++) {
    if (g[v][i] == par) {
      b = true;
      continue;
    }
    ++count;
    dfs(g[v][i], v, timenow + 1);
    ++timenow;
    ans.push_back({v, timenow});
  }
  if (need == g[v].size() - 1) {
    timenow = val;
    ans.push_back({v, timenow});
    return;
  }
  if (need <= 0) {
    timenow = val - g[v].size() + 1;
  } else {
    timenow = 0;
  }
  if (b) need += 1;
  ans.push_back({v, timenow});
  for (int i = max(0, need); i < g[v].size(); i++) {
    if (g[v][i] == par) continue;
    dfs(g[v][i], v, timenow + 1);
    ++timenow;
    ans.push_back({v, timenow});
  }
}
int main() {
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  dfs(1, -1, 0);
  cout << "\n" << ans.size() << "\n";
  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i].first << " " << ans[i].second << "\n";
  }
}
