#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > ans;
vector<int> v[8001];
int a[8001], one, two, n, i, j, z, k, kol;
bool dp[8001], pole[8001];
void dfs(int nom, int last) {
  int i;
  kol++;
  for (i = 0; i < v[nom].size(); i++)
    if (v[nom][i] != last) dfs(v[nom][i], nom);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (i = 1; i <= n - 1; i++) {
    cin >> one >> two;
    v[one].push_back(two);
    v[two].push_back(one);
  }
  for (z = 1; z <= n; z++)
    if (v[z].size() > 1) {
      k = 0;
      for (i = 0; i < v[z].size(); i++) {
        kol = 0;
        dfs(v[z][i], z);
        k++;
        a[k] = kol;
      }
      for (i = 1; i <= n; i++) dp[i] = false;
      dp[0] = true;
      for (i = 1; i <= k; i++)
        for (j = n; j >= 0; j--)
          if (dp[j] && j + a[i] <= n) dp[j + a[i]] = pole[j + a[i]] = true;
    }
  for (i = 1; i <= n - 2; i++)
    if (pole[i]) ans.push_back(make_pair(i, (n - 1) - i));
  cout << ans.size() << '\n';
  for (pair<int, int> e : ans) cout << e.first << " " << e.second << '\n';
  return 0;
}
