#include <bits/stdc++.h>
using namespace std;
const int maxn = 100100;
int N;
vector<pair<int, int> > ans;
vector<int> E[maxn];
void go(int i, int t) { ans.push_back({i, t}); }
void dfs(int i, int p, int t) {
  go(i, t);
  int d = (t < E[i].size());
  if (!d) t -= E[i].size(), go(i, t);
  for (auto &j : E[i])
    if (j != p) {
      t++;
      dfs(j, i, t);
      go(i, t);
      if (d && t == E[i].size()) t -= E[i].size(), go(i, t);
    }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  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);
  }
  go(1, 0);
  int t = 0;
  for (auto &i : E[1]) t++, dfs(i, 1, t), go(1, t);
  cout << ans.size() << "\n";
  for (auto &i : ans) cout << i.first << " " << i.second << "\n";
}
