#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> g[n + 1];
  for (int i = 0; i < n - 1; ++i) {
    int x, y;
    cin >> x >> y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  vector<bool> ans(n + 1);
  int cnt = 0;
  for (int i = 1; i <= n; ++i) {
    int id = 0;
    vector<bool> vis(n + 1);
    vector<int> sum(n + 1);
    vis[i] = 1;
    function<void(int)> dfs = [&](int u) {
      vis[u] = 1;
      sum[id] += 1;
      for (auto v : g[u]) {
        if (!vis[v]) {
          dfs(v);
        }
      }
    };
    for (int j : g[i]) {
      if (!vis[j]) {
        dfs(j);
        id++;
      }
    }
    vector<bool> dp(n + 1);
    dp[0] = 1;
    for (int j = 0; j < id; ++j) {
      for (int k = n; k >= 0; --k) {
        if (dp[k] && k + sum[j] <= n) {
          dp[k + sum[j]] = 1;
        }
      }
    }
    for (int j = 1; j < n - 1; ++j) {
      if (dp[j]) {
        if (!ans[j]) {
          ++cnt;
        }
        ans[j] = 1;
      }
    }
  }
  cout << cnt << '\n';
  for (int i = 1; i < n - 1; ++i) {
    if (ans[i]) {
      cout << i << ' ' << n - 1 - i << '\n';
    }
  }
  return 0;
}
