#include <bits/stdc++.h>
using namespace std;
const int maxn = 100005;
vector<vector<int> > neighbours(maxn);
vector<pair<int, int> > path;
void inline dfs(int u, int parent, int x, int d) {
  int y = x;
  path.push_back(make_pair(u + 1, y));
  for (int i = 0; i < neighbours[u].size(); i++) {
    int v = neighbours[u][i];
    if (v == parent) continue;
    if (y == d) {
      y = d - (int)neighbours[u].size();
      path.push_back(make_pair(u + 1, y));
    }
    dfs(v, u, y + 1, d);
    y++;
    path.push_back(make_pair(u + 1, y));
  }
  if (y == (x + (int)neighbours[u].size() - 1)) {
    y = x - 1;
    path.push_back(make_pair(u + 1, y));
  }
}
int main() {
  int n;
  cin >> n;
  int a, b;
  for (int i = 0; i < n - 1; i++) {
    cin >> a >> b;
    a--, b--;
    neighbours[a].push_back(b), neighbours[b].push_back(a);
  }
  int maxd = 0;
  for (int i = 0; i < n; i++) maxd = max(maxd, (int)neighbours[i].size());
  dfs(0, -1, 0, maxd);
  cout << path.size() << endl;
  for (int i = 0; i < path.size(); i++)
    cout << path[i].first << ' ' << path[i].second << endl;
  return 0;
}
