#include <bits/stdc++.h>
using namespace std;
long long d[200005];
vector<long long> adj[200005];
vector<pair<long long, long long>> ans;
long long T;
void rec(long long u, long long p, long long t) {
  ans.push_back({u, t});
  long long ti = t;
  long long f = 0;
  for (auto i : adj[u]) {
    if (i != p) {
      ti++;
      f++;
      if (ti % (T + 1) == 0) {
        if (d[u] - 1 - f < t - 1)
          ti = t - d[u] + f - 1;
        else
          ti = ti % (T + 1);
        ans.push_back({u, ti});
        ti++;
      }
      rec(i, u, ti);
    }
  }
  if (u == 1) return;
  if (ti != (t - 1 + T + 1) % (T + 1))
    ans.push_back({u, (t - 1 + T + 1) % (T + 1)});
  ans.push_back({p, t});
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n;
  cin >> n;
  for (long long i = 0; i < n - 1; i++) {
    long long u, v;
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
    d[u]++, d[v]++;
    T = max(T, d[u]);
    T = max(T, d[v]);
  }
  rec(1, 0, 0);
  cout << ans.size() << "\n";
  for (auto i : ans) cout << i.first << " " << i.second << "\n";
}
