#include <bits/stdc++.h>
using namespace std;
int m = 0;
vector<int> G[200002];
void dfs(int u, int p, int d) {
  cout << u << ' ' << d << '\n';
  int c = d, tmp = G[u].size() - 1;
  for (auto& v : G[u]) {
    if (v != p) {
      if (c == m) {
        c = d - tmp - 1;
        cout << u << ' ' << c << '\n';
      }
      dfs(v, u, ++c);
      --tmp;
      cout << u << ' ' << c << '\n';
    }
  }
  if (c + 1 != d && u != 1) cout << u << ' ' << d - 1 << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i < n; ++i) {
    int u, v;
    cin >> u >> v;
    G[u].push_back(v), G[v].push_back(u);
  }
  int ans = 0;
  for (int u = 1; u <= n; ++u) {
    m = max((int)G[u].size(), m);
    ans += G[u].size() + 1;
  }
  cout << ans << '\n';
  dfs(1, 0, 0);
}
