#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
const int N = 100005;
vector<int> adj[N];
vector<ii> ans;
int mx = 0;
int dfs(int x, int t, int p = -1) {
  ans.push_back({x, t});
  int y = t;
  int k = (int)adj[x].size() - 1;
  if (t - 1 - k >= 0 && t - 1 - k != t) {
    ans.push_back({x, t - 1 - k});
    y = t - 1 - k;
  }
  for (int i : adj[x])
    if (i != p) {
      if (y + 1 > mx) {
        ans.push_back({x, t - 1 - k});
        y = t - 1 - k;
      }
      y = dfs(i, y + 1, x) + 1;
      ans.push_back({x, y});
      k--;
    }
  if (t && y != t - 1) ans.push_back({x, t - 1});
  t--;
  return t;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    adj[a].push_back(b);
    adj[b].push_back(a);
    mx = max((int)adj[a].size(), mx);
    mx = max((int)adj[b].size(), mx);
  }
  dfs(1, 0);
  printf("%d\n", (int)ans.size());
  for (ii i : ans) {
    printf("%d %d\n", i.first, i.second);
  }
  return 0;
}
