#include <bits/stdc++.h>
using namespace std;
int inline read() {
  int num = 0, neg = 1;
  char c = getchar();
  while (!isdigit(c)) {
    if (c == '-') neg = -1;
    c = getchar();
  }
  while (isdigit(c)) {
    num = (num << 3) + (num << 1) + c - '0';
    c = getchar();
  }
  return num * neg;
}
const int maxn = 100010, mod = 998244353;
int n, deg[maxn], T;
vector<int> g[maxn];
vector<pair<int, int> > ans;
void dfs(int x, int fa, int t) {
  int son = deg[x] - (x != 1), now = t;
  for (int i = 0; i < g[x].size(); i++) {
    int v = g[x][i];
    if (v == fa) continue;
    if (now == T) {
      ans.push_back(make_pair(x, t - son - 1));
      ans.push_back(make_pair(v, t - son));
      dfs(v, x, t - son);
      ans.push_back(make_pair(x, t - son));
      now = t - son;
    } else {
      ans.push_back(make_pair(v, now + 1));
      dfs(v, x, now + 1);
      ans.push_back(make_pair(x, now + 1));
      now++;
    }
    son--;
  }
  if (x != 1 && (now != t - 1)) ans.push_back(make_pair(x, t - 1));
}
int main() {
  n = read();
  for (int i = 1; i < n; i++) {
    int x = read(), y = read();
    g[x].push_back(y);
    g[y].push_back(x);
    deg[x]++;
    deg[y]++;
    T = max(T, max(deg[x], deg[y]));
  }
  ans.push_back(make_pair(1, 0));
  dfs(1, 0, 0);
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); i++)
    cout << ans[i].first << " " << ans[i].second << endl;
  return 0;
}
