#include <bits/stdc++.h>
using namespace std;
const int N = 1 + 1e5;
vector<int> tree[N];
inline void move(int x, int t) { printf("%d %d\n", x, t); }
void dfs(int x, int T, int p) {
  move(x, ++p);
  int delta = max(0, p - (int)tree[x].size());
  for (int y : tree[x]) {
    if (y == T) continue;
    if (p == tree[x].size() + delta) {
      move(x, delta);
      p = delta;
    }
    dfs(y, x, p);
    move(x, ++p);
  }
  if (p == tree[x].size() + delta) move(x, delta);
}
void print_sol(int n) {
  printf("%d\n", 3 * n - 2);
  int p = 0;
  for (int x : tree[1]) {
    move(1, p);
    dfs(x, 1, p++);
  }
  move(1, p);
}
int main() {
  int n, x, y;
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    scanf("%d%d", &x, &y);
    tree[x].push_back(y);
    tree[y].push_back(x);
  }
  print_sol(n);
  return 0;
}
