#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
vector<int> adj[int(1e5) + 1];
int vis[int(1e5) + 1];
int n1;
map<pair<int, int>, int> mp;
int dfs(int i) {
  vis[i] = 1;
  int num;
  vector<int> v;
  for (auto u : adj[i]) {
    if (!vis[u]) {
      num = dfs(u);
      v.emplace_back(num);
    }
  }
  if (v.size()) {
    int sum = 0, n = v.size();
    for (int k = 0; k < n; k++) sum += v[k];
    bool dp[n + 1][sum + 1];
    memset(dp, 0, sizeof(dp));
    for (int k = 0; k <= n; k++) dp[k][0] = true;
    for (int k = 1; k <= n; k++) {
      dp[k][v[k - 1]] = true;
      for (int j = 1; j <= sum; j++) {
        if (dp[k - 1][j] == true) {
          dp[k][j] = true;
          dp[k][j + v[k - 1]] = true;
        }
      }
    }
    for (int j = 0; j <= sum; j++)
      if (dp[n][j] == true) {
        mp[make_pair(j, n1 - j - 1)] = 1, mp[make_pair(n1 - j - 1, j)] = 1;
      }
  }
  return accumulate((v).begin(), (v).end(), 1);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int i, u, v, j;
  cin >> n1;
  for (i = 1; i <= n1 - 1; i++) {
    cin >> u >> v;
    adj[u].emplace_back(v);
    adj[v].emplace_back(u);
  }
  int p = dfs(1);
  vector<pair<int, int> > vec;
  for (i = 1; i <= n1; i++) {
    for (j = 1; j <= n1; j++)
      if (mp.find({i, j}) != mp.end()) vec.emplace_back(make_pair(i, j));
  }
  cout << vec.size() << "\n";
  for (auto u : vec) cout << u.first << " " << u.second << "\n";
  return 0;
}
