#include <bits/stdc++.h>
using namespace std;
using INT = long long;
using pii = pair<int, int>;
vector<int> adj[100100];
vector<pii> ans;
int mx = 0;
void dfs(int u, int fa = 0, int t = 0) {
  ans.push_back(pii(u, t));
  int T = t, tt = 0, ok = 0;
  vector<int> tmp;
  for (int v : adj[u]) {
    if (v == fa) continue;
    if (T < mx) {
      dfs(v, u, T + 1);
      ans.push_back(pii(u, T + 1));
      T++;
      continue;
    }
    tmp.push_back(v);
  }
  if (!tmp.empty()) {
    tt = t - tmp.size() - 1;
    ans.push_back(pii(u, tt));
    for (int v : tmp) {
      dfs(v, u, tt + 1);
      ans.push_back(pii(u, tt + 1));
      tt++;
    }
  } else {
    if (t) ans.push_back(pii(u, t - 1));
  }
}
int main() {
  int n;
  cin >> n;
  for (int i = 1; i < n; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  for (int i = 1; i <= n; i++) mx = max(mx, (int)adj[i].size());
  dfs(1);
  cout << ans.size() << endl;
  for (auto p : ans) printf("%d %d\n", p.first, p.second);
}
