#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
int n, mad;
vector<int> e[100010];
vector<pair<int, int> > ans;
void dfs(int v, int& t, int backT = -1, int p = -1) {
  ans.emplace_back(v, t);
  int cntTo = 0;
  for (auto u : e[v]) {
    if (u != p) ++cntTo;
  }
  for (auto to : e[v]) {
    if (to == p) continue;
    if (t == mad) {
      t = backT - 1 - cntTo;
      ans.emplace_back(v, t);
    }
    t++;
    dfs(to, t, t, v);
    ans.emplace_back(v, t);
    --cntTo;
  }
  if (p == -1) return;
  if (t >= backT) {
    t = backT - 1;
    ans.emplace_back(v, t);
  }
  t++;
}
void solve() {
  int t = 0;
  dfs(0, t);
  cout << ans.size() << "\n";
  for (auto s : ans) {
    cout << s.first + 1 << " " << s.second << "\n";
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n;
  int u, v;
  for (int i = int(0); i < int(n - 1); i++) {
    cin >> u >> v;
    --u, --v;
    e[u].push_back(v);
    e[v].push_back(u);
  }
  mad = 0;
  for (int i = int(0); i < int(n); i++) mad = max(mad, (int)e[i].size());
  solve();
  return 0;
}
