#include <bits/stdc++.h>
using namespace std;
int N, M;
const int MAXN = 2e5 + 15;
vector<int> E[MAXN];
void dfs(int n, int p, int d) {
  cout << n << " " << d << endl;
  int c = d, t = E[n].size() - 1;
  for (auto& v : E[n])
    if (v != p) {
      if (c == M) {
        c = d - t - 1;
        cout << n << " " << c << endl;
      }
      ++c;
      dfs(v, n, c);
      --t;
      cout << n << " " << c << endl;
    }
  if (c + 1 != d && n != 1) cout << n << " " << d - 1 << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  cin >> N;
  for (int i = 0; i < N - 1; ++i) {
    int a, b;
    cin >> a >> b;
    E[a].push_back(b);
    E[b].push_back(a);
  }
  int ans = 0;
  for (int i = 1; i <= N; ++i) {
    M = max((int)E[i].size(), M);
    ans += E[i].size() + 1;
  }
  cout << ans << endl;
  dfs(1, 0, 0);
}
