#include <bits/stdc++.h>
using namespace std;
int n, tot, ans, b[10005], h[10005], e[10005], s[10005], v[10005], p[10005],
    f[10005];
int en, g[10005];
void Add(int x, int y) {
  b[++tot] = y;
  e[tot] = h[x];
  h[x] = tot;
}
void Dp(int k) {
  memset(p, 0, sizeof(p));
  p[0] = 1;
  for (int i = 0; i < en; i++)
    for (int j = n - 2; j >= 1; j--)
      if (j - g[i] >= 0 && p[j - g[i]]) p[j] = 1;
  for (int i = 1; i < n; i++)
    if (p[i]) v[i] = 1;
}
void Dfs(int x, int fa) {
  s[x] = 1;
  f[x] = fa;
  for (int go = h[x]; go; go = e[go])
    if (b[go] != fa) Dfs(b[go], x), s[x] += s[b[go]];
}
void Work() {
  for (int i = 0; i < n; i++) {
    en = 0;
    for (int go = h[i]; go; go = e[go])
      if (b[go] != f[i]) g[en++] = s[b[go]];
    g[en++] = (s[0] - s[i]);
    Dp(i);
  }
}
int main() {
  scanf("%d", &n);
  int x, y;
  for (int i = 1; i < n; i++) {
    scanf("%d%d", &x, &y);
    Add(--x, --y);
    Add(y, x);
  }
  Dfs(0, 0);
  Work();
  for (int i = 1; i < n; i++)
    if (v[i]) ans++;
  printf("%d\n", ans);
  for (int i = 1; i < n; i++)
    if (v[i]) printf("%d %d\n", i, n - i - 1);
  return 0;
}
