#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> gr;
vector<pair<int, int>> sol;
void dfs(int u = 0, int p = 0, int s = 0) {
  int x = s, n = gr[u].size();
  sol.push_back({u, x});
  int d = 1;
  for (int i = 0; i < n; i++) {
    int v = gr[u][i];
    if (v == p) {
      d = 0;
      continue;
    }
    if (s - (n - i) - 1 + d >= 0 and x != s - (n - i) - 1 + d) {
      x = s - (n - i) - 1 + d;
      sol.push_back({u, x});
    }
    x++;
    dfs(v, u, x);
    sol.push_back({u, x});
  }
  if (s - 1 >= 0 and x != s - 1) {
    x = s - 1;
    sol.push_back({u, x});
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  gr.resize(n);
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    gr[u].push_back(v);
    gr[v].push_back(u);
  }
  dfs();
  cout << sol.size() << '\n';
  for (auto p : sol) cout << p.first + 1 << ' ' << p.second << '\n';
  return 0;
}
