#include <bits/stdc++.h>
using namespace std;
const int maxn = 100100;
int N;
vector<pair<int, int> > ans;
vector<int> E[maxn];
void dfs(int i, int p, int t) {
  ans.push_back(make_pair(i, t));
  int d = (t < E[i].size());
  if (!d) t -= E[i].size(), ans.push_back(make_pair(i, t));
  for (int j = 0; j < E[i].size(); j++) {
    if (E[i][j] != p) {
      t++;
      dfs(E[i][j], i, t);
      ans.push_back(make_pair(i, t));
      if (d && t == E[i].size())
        t -= E[i].size(), ans.push_back(make_pair(i, t));
    }
  }
}
int main() {
  cin >> N;
  int u, v;
  for (int i = 1; i < N; i++) {
    cin >> u >> v;
    E[u].push_back(v);
    E[v].push_back(u);
  }
  ans.push_back(make_pair(1, 0));
  int t = 0;
  for (int i = 0; i < E[1].size(); i++) {
    t++;
    dfs(E[1][i], 1, t);
    ans.push_back(make_pair(1, t));
  }
  cout << ans.size() << "\n";
  for (int i = 0; i < ans.size(); i++)
    cout << ans[i].first << " " << ans[i].second << "\n";
}
