#include <bits/stdc++.h>
using namespace std;
int st[20000], lk[20000], f[20000], a[20000], b[20000], m = 0, n, num;
bool visit[20000], ans[20000];
void connect(int x, int y) {
  a[m] = x;
  b[m] = y;
  m++;
}
void DFS(int x) {
  if (visit[x]) return;
  visit[x] = 1;
  num++;
  for (int i = st[x]; i != -1; i = lk[i]) {
    DFS(b[i]);
  }
}
int main() {
  scanf("%d", &n);
  int x, y;
  for (int i = 0; i < n + n; i++) st[i] = -1;
  for (int i = 0; i < n + n; i++) lk[i] = -1;
  for (int i = 0; i < n - 1; i++) {
    scanf("%d%d", &x, &y);
    connect(x - 1, y - 1);
    connect(y - 1, x - 1);
  }
  for (int i = 0; i < m; i++) {
    lk[i] = st[a[i]];
    st[a[i]] = i;
  }
  memset(ans, 0, sizeof(ans));
  for (int i = 0; i < n; i++) {
    num = 0;
    memset(visit, 0, sizeof(visit));
    memset(f, 0, sizeof(f));
    f[0] = 1;
    visit[i] = 1;
    for (int k = st[i]; k != -1; k = lk[k]) {
      num = 0;
      DFS(b[k]);
      for (int j = n - 2; j >= num; j--)
        if (f[j - num]) f[j] = 1;
    }
    for (int j = 1; j <= n - 2; j++)
      if (f[j]) ans[j] = 1;
  }
  int sum = 0;
  for (int i = 1; i < n - 1; i++) sum += ans[i];
  cout << sum << endl;
  for (int i = 1; i < n - 1; i++)
    if (ans[i]) cout << i << ' ' << n - i - 1 << endl;
}
