#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 123;
int n, t, label[N], times = 0;
vector<int> e[N];
vector<pair<int, int> > res;
void newLabel(int u) {
  res.push_back(make_pair(u, times));
  label[u] = times;
}
void dfs(int u, int backLabel = -1, int p = 0) {
  newLabel(u);
  int numchild = (int)e[u].size() - (u > 1);
  for (int v : e[u]) {
    if (v == p) continue;
    if (label[u] >= t) {
      times = backLabel - numchild;
      newLabel(u);
    }
    times = label[u] + 1;
    dfs(v, label[u], u);
    if (label[v] > label[u]) {
      times = label[u];
      newLabel(v);
    }
    ++times;
    newLabel(u);
    --numchild;
  }
  if (u > 1 && label[u] > backLabel) {
    times = backLabel;
    newLabel(u);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie();
  cout.tie();
  cin >> n;
  for (int i = 1; i < n; ++i) {
    int u, v;
    cin >> u >> v;
    e[u].push_back(v);
    e[v].push_back(u);
  }
  t = -1;
  for (int i = 1; i <= n; ++i) t = max(t, (int)e[i].size());
  dfs(1);
  cout << res.size() << "\n";
  for (pair<int, int> x : res) {
    cout << x.first << " " << x.second << "\n";
  }
  return 0;
}
