#include <bits/stdc++.h>
using namespace std;
vector<int> g[100005];
vector<pair<int, int> > ans;
int t, mx;
void dfs(int v, int tr, int p) {
  ans.push_back({v, t});
  int kol = int(g[v].size()) - 1;
  for (auto it : g[v]) {
    if (it == p) continue;
    if (mx == t) {
      t = tr - 1 - kol;
      ans.push_back({v, t});
    }
    t++;
    kol--;
    dfs(it, t, v);
    ans.push_back({v, t});
  }
  if (tr == -1) return;
  if (t >= tr) {
    t = tr - 1;
    ans.push_back({v, t});
  }
  t++;
}
int main() {
  ios_base::sync_with_stdio(0);
  istream::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i < n; i++) {
    int a, b;
    cin >> a >> b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  for (int i = 1; i <= n; i++) mx = max(mx, int(g[i].size()));
  dfs(1, -1, -1);
  cout << int(ans.size()) << '\n';
  for (auto it : ans) cout << it.first << " " << it.second << '\n';
}
