#include <bits/stdc++.h>
using namespace std;
vector<int> adj[100010];
bitset<100010> vis;
vector<pair<int, int> > traverse;
void bfs(int i, int curr_t, int &max_t) {
  vis[i] = true;
  int ki_nie_aschi = curr_t;
  traverse.emplace_back(i, curr_t);
  int x;
  int baki_ase = adj[i].size() - 1;
  for (int j = 0; j < (int)adj[i].size(); j++) {
    x = adj[i][j];
    if (!vis[x]) {
      if (curr_t + 1 <= max_t) {
        bfs(x, curr_t + 1, max_t);
      } else {
        curr_t = ki_nie_aschi - baki_ase - 1;
        traverse.emplace_back(i, curr_t);
        bfs(x, curr_t + 1, max_t);
      }
      --baki_ase;
      traverse.emplace_back(x, curr_t);
      traverse.emplace_back(i, curr_t + 1);
      curr_t += 1;
    }
  }
}
int main() {
  int n, a, b;
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    cin >> a >> b;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  int mx = -1e9;
  for (int i = 1; i <= n; i++) mx = max(mx, (int)adj[i].size());
  bfs(1, 0, mx);
  int size = unique(traverse.begin(), traverse.end()) - traverse.begin();
  cout << size << '\n';
  for (int i = 0; i < size; i++) {
    auto x = traverse[i];
    cout << x.first << ' ' << x.second << '\n';
  }
  return 0;
}
