#include <bits/stdc++.h>
using namespace std;
constexpr int kN = int(1E5 + 10);
vector<int> graph[kN];
vector<pair<int, int>> ans;
bool dfs(int pos, int from, int val, int x, bool f) {
  if (val > x) return false;
  if (pos == 1) {
    if (f) ans.push_back({1, 0});
    int now = 0;
    for (int i : graph[pos])
      if (!dfs(i, pos, ++now, x, f)) return false;
    return now <= x;
  } else {
    if (f) ans.push_back({pos, val});
    int now = val, cnt = int(graph[pos].size());
    cnt--;
    if (cnt + 2 > x + 1)
      return false;
    else if (cnt + val <= x) {
      for (int i : graph[pos])
        if (i != from) {
          if (!dfs(i, pos, ++now, x, f)) return false;
        }
      if (f) {
        ans.push_back({pos, val - 1});
        ans.push_back({from, val});
      }
      return true;
    } else {
      for (int i : graph[pos])
        if (i != from) {
          if (now < x) {
            if (!dfs(i, pos, ++now, x, f)) return false;
            cnt--;
          } else {
            now = val - 1 - cnt;
            if (f) ans.push_back({pos, now});
            if (!dfs(i, pos, ++now, x, f)) return false;
          }
        }
      if (f) ans.push_back({from, val});
      return true;
    }
  }
}
int main() {
  int n, l, r, mid;
  scanf("%d", &n);
  if (n == 1) {
    printf("1\n1 0\n");
    return 0;
  }
  for (int i = 1; i < n; i++) {
    scanf("%d%d", &l, &r);
    graph[l].push_back(r);
    graph[r].push_back(l);
  }
  l = 0, r = n;
  while (r - l > 1) {
    mid = (l + r) >> 1;
    if (dfs(1, 1, 0, mid, false))
      r = mid;
    else
      l = mid;
  }
  dfs(1, 1, 0, r, true);
  printf("%d\n", int(ans.size()));
  for (pair<int, int> i : ans) printf("%d %d\n", i.first, i.second);
}
