#include <bits/stdc++.h>
using namespace std;
mt19937 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
const long double PI = 3.141592653589793;
const long long INF = 9223372036854775807ll;
const long long mod = 1e9 + 7;
const int N = 1e5 + 2;
vector<int> adj[N];
vector<pair<int, int>> pr;
void calc(int u, int p, int val) {
  int temp = val;
  pr.push_back({u, val});
  if (!u) {
    for (int v : adj[u]) {
      calc(v, u, ++val);
      pr.push_back({u, val});
    }
  } else {
    int c = (int)adj[u].size();
    if (c <= val) {
      pr.push_back({u, val - c});
      int s = val - c;
      for (int v : adj[u]) {
        if (v != p) {
          calc(v, u, ++s);
          pr.push_back({u, s});
        }
      }
    } else {
      int s = val;
      for (int v : adj[u]) {
        if (v != p) {
          if (s == c) {
            s = 0;
            pr.push_back({u, 0});
          }
          calc(v, u, ++s);
          pr.push_back({u, s});
        }
      }
      if (temp == 1) {
        pr.push_back({u, 0});
      }
    }
  }
}
void solve() {
  int n;
  cin >> n;
  for (int i = 0; i < n - 1; ++i) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  calc(0, -1, 0);
  cout << pr.size() << '\n';
  for (auto x : pr) {
    cout << (x.first + 1) << " " << x.second << '\n';
  }
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  srand(chrono::high_resolution_clock::now().time_since_epoch().count());
  solve();
  return 0;
}
