#include <bits/stdc++.h>
using namespace std;
const int maxn = 5000 + 10;
vector<int> graph[maxn];
int N, sz[maxn];
int can[maxn];
int memo[maxn][maxn];
int dp(int pos, int cnt, vector<int> &nodes) {
  if (cnt < 0) return 0;
  if (pos < 0) {
    if (cnt == 0) return 1;
    return 0;
  }
  int &res = memo[pos][cnt];
  if (res != -1) return res;
  int u = nodes[pos];
  res = dp(pos - 1, cnt, nodes);
  res |= dp(pos - 1, cnt - sz[u], nodes);
  return res;
}
void dfs(int u, int p) {
  sz[u] = 1;
  vector<int> nodes;
  for (auto &v : graph[u]) {
    if (v == p) continue;
    dfs(v, u);
    sz[u] += sz[v];
    nodes.push_back(v);
  }
  if (nodes.size()) {
    for (int i = 0; i < nodes.size(); i++)
      for (int j = 0; j < N; j++) memo[i][j] = -1;
    for (int i = N; i >= 0; i--) {
      int r = dp(nodes.size() - 1, i, nodes);
      if (r) can[i] = 1;
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> N;
  for (int i = 0; i < N - 1; i++) {
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    graph[u].push_back(v);
    graph[v].push_back(u);
  }
  dfs(0, 0);
  vector<int> res;
  for (int i = 1; i < N - 1; i++)
    if (can[i]) {
      res.push_back(i);
      res.push_back(N - i - 1);
    }
  sort((res).begin(), (res).end());
  res.erase(unique(res.begin(), res.end()), res.end());
  cout << res.size() << '\n';
  for (int i = 0; i < res.size(); i++) {
    cout << res[i] << ' ' << N - res[i] - 1 << '\n';
  }
  return 0;
}
