#include <bits/stdc++.h>
using namespace std;
const long long maxn = 2e5 + 10;
const long long mod = 1e9 + 7;
const long long base = 3e18;
vector<long long> adj[maxn];
long long ans = 0;
vector<pair<long long, long long> > vt;
void dfs(long long u, long long par, long long nw) {
  vt.push_back(make_pair(u, nw));
  long long cnt = 0;
  vector<long long> gr;
  for (auto to : adj[u]) {
    if (to == par) continue;
    gr.push_back(to);
  }
  long long h = nw;
  for (auto to : gr) {
    if (cnt + 1 + h <= ans) {
      cnt++;
      dfs(to, u, cnt + h);
    } else {
      long long cl = gr.size() - cnt;
      vt.push_back(make_pair(u, nw - cl - 1));
      h = nw - cl - 1;
      cnt = 1;
      dfs(to, u, cnt + h);
    }
  }
  if (nw + gr.size() <= ans) {
    vt.push_back(make_pair(u, nw - 1));
  }
  vt.push_back(make_pair(par, nw));
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  if (fopen("t.inp", "r")) {
    freopen("test.inp", "r", stdin);
    freopen("test.out", "w", stdout);
  }
  long long n;
  cin >> n;
  for (int i = 1; i <= n - 1; i++) {
    long long x, y;
    cin >> x >> y;
    adj[x].push_back(y);
    adj[y].push_back(x);
    ans = max(ans, (long long)adj[x].size());
    ans = max(ans, (long long)adj[y].size());
  }
  vt.push_back(make_pair(1, 0));
  long long cnt = 0;
  for (auto to : adj[1]) {
    dfs(to, 1, cnt + 1);
    cnt++;
  }
  cout << vt.size() << "\n";
  for (auto to : vt) {
    cout << to.first << " " << to.second << "\n";
  }
}
