#include <bits/stdc++.h>
using namespace std;
int n;
vector<vector<int>> nearby;
vector<int> weight;
vector<vector<int>> wofChild;
void dfs(int v, int previ) {
  weight[v] = 1;
  for (auto to : nearby[v]) {
    if (to != previ) {
      dfs(to, v);
      wofChild[v].push_back(weight[to]);
      weight[v] += weight[to];
    }
  }
}
void solve() {
  vector<bool> can(n + 1, false);
  can[0] = true;
  for (int em = 0; em < n; ++em) {
    vector<bool> dp(n + 1, false);
    dp[0] = true;
    for (int i = 0; i < wofChild[em].size(); ++i) {
      for (int s = n; s >= 0; --s) {
        if (dp[s] && !dp[s + wofChild[em][i]]) {
          dp[s + wofChild[em][i]] = true;
        }
      }
    }
    int parentComponent = n - weight[em];
    for (int s = n; s >= 0; --s) {
      if (dp[s] && !dp[s + parentComponent]) {
        dp[s + parentComponent] = true;
      }
    }
    for (int s = 1; s <= n; ++s) {
      if (dp[s]) {
        can[s] = true;
      }
    }
  }
  vector<int> anses;
  for (int s = 1; s < n - 1; ++s) {
    if (can[s]) {
      anses.push_back(s);
    }
  }
  printf("%u\n", anses.size());
  for (auto elem : anses) {
    printf("%d %d\n", elem, n - 1 - elem);
  }
  return;
}
int main() {
  scanf("%d", &n);
  nearby = vector<vector<int>>(n);
  for (int i = 0; i < n - 1; ++i) {
    int fi, se;
    scanf("%d%d", &fi, &se);
    nearby[fi - 1].push_back(se - 1);
    nearby[se - 1].push_back(fi - 1);
  }
  int start = 0;
  weight = vector<int>(n);
  wofChild = vector<vector<int>>(n);
  dfs(start, -1);
  solve();
  return 0;
}
