#include <bits/stdc++.h>
using namespace std;
const int N = 1e4;
int n;
int ans;
int s[N];
bool v[N];
bool f[N];
bool dp[N];
int st[N], nex[N], en[N], l;
inline int read() {
  int f = 1;
  int s = 0;
  char x = getchar();
  while (!isdigit(x)) {
    if (x == '-') f = -1;
    x = getchar();
  }
  while (isdigit(x)) s = s * 10 + x - '0', x = getchar();
  return s * f;
}
void insert(int x, int y) {
  nex[++l] = st[x];
  st[x] = l;
  en[l] = y;
}
int dfs(int i) {
  if (v[i]) return 0;
  int j, sum = 1;
  v[i] = 1;
  for (j = st[i]; j; j = nex[j]) {
    if (v[en[j]]) continue;
    sum += dfs(en[j]);
  }
  return sum;
}
int main() {
  int i, j, r;
  n = read();
  for (i = 1; i < n; i++) {
    int x = read(), y = read();
    insert(x, y);
    s[x]++;
    insert(y, x);
    s[y]++;
  }
  for (i = 1; i <= n; i++) {
    if (s[i] < 2) continue;
    fill(v, v + N, 0);
    fill(f, f + N, 0);
    f[0] = 1;
    v[i] = 1;
    for (j = st[i]; j; j = nex[j]) {
      int sum = dfs(en[j]);
      for (r = n - 2; r >= sum; r--)
        if (f[r - sum]) f[r] = 1;
    }
    for (j = 1; j < n - 1; j++)
      if (!dp[j] && f[j]) dp[j] = f[j], ans++;
  }
  cout << ans << endl;
  for (i = 1; i < n - 1; i++)
    if (dp[i]) cout << i << " " << n - 1 - i << endl;
  return 0;
}
