#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
const long long MOD = 998244353;
const int INF = (int)1e9;
inline long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
inline long long lb(long long x) { return x & -x; }
long long qpow(long long base, int n) {
  if (base == 0) return 0;
  long long ans = 1;
  while (n) {
    if (n & 1) ans *= base;
    ans %= MOD;
    n >>= 1;
    base = base * base % MOD;
  }
  return ans;
}
int n, k;
vector<int> g[maxn];
int T;
bool op;
void dfs(int u, int t, int fa) {
  int nt = t;
  ++k;
  if (op) {
    printf("%d %d\n", u, nt);
  }
  int son = g[u].size() - 1;
  if (t > son) {
    ++k;
    t = t - son - 1;
    if (op) printf("%d %d\n", u, t);
    for (auto &v : g[u]) {
      if (v == fa) continue;
      ++t;
      dfs(v, t, u);
      ++k;
      if (op) printf("%d %d\n", u, t);
    }
  } else {
    for (auto &v : g[u]) {
      if (v == fa) continue;
      ++t;
      dfs(v, t, u);
      ++k;
      if (op) printf("%d %d\n", u, t);
      if (t == son + 1 && u != 1) {
        ++k;
        if (op) printf("%d %d\n", u, 0);
        t = 0;
      }
    }
  }
}
int main() {
  cin >> n;
  if (n == 1) {
    printf("1\n1 0\n");
    return 0;
  }
  for (int i = 1; i < n; ++i) {
    int u, v;
    scanf("%d %d", &u, &v);
    g[u].push_back(v);
    g[v].push_back(u);
  }
  for (int i = 1; i <= n; ++i) {
    int tmp = g[i].size();
    T = max(tmp, T);
  }
  dfs(1, 0, 0);
  printf("%d\n", k);
  op = 1;
  dfs(1, 0, 0);
}
