#include <bits/stdc++.h>
using namespace std;
vector<int> edge[100005];
vector<pair<int, int> > ans;
int T;
void f(int node, int par, int val, int last) {
  ans.push_back({node, val});
  int unseen = (int)edge[node].size() - (node == 1 ? 0 : 1);
  for (auto other : edge[node]) {
    if (other == par) continue;
    if (val == T + 1) {
      val = last - unseen;
      ans.push_back({node, val});
    }
    f(other, node, val + 1, val);
    ans.push_back({node, val + 1});
    val++;
    unseen--;
  }
  if (val != last && node != 1) ans.push_back({node, last});
}
int main() {
  ios_base ::sync_with_stdio(false);
  int n;
  cin >> n;
  int x, y;
  for (int i = 0; i < n - 1; i++) {
    cin >> x >> y;
    edge[x].push_back(y);
    edge[y].push_back(x);
  }
  for (int i = 1; i <= n; i++) T = max(T, (int)edge[i].size() - 1);
  f(1, 1, 0, 0);
  cout << (int)ans.size() << endl;
  for (auto p : ans) cout << p.first << ' ' << p.second << endl;
}
