#include <bits/stdc++.h>
using namespace std;
int iin() {
  int x;
  scanf("%d", &x);
  return x;
}
const int N = 1000 * 5 + 100;
vector<int> adj[N];
int n, sz[N];
bool nap[N], ans[N];
void dfs(int c, int p) {
  sz[c]++;
  for (int ne : adj[c]) {
    if (ne == p) continue;
    dfs(ne, c);
    sz[c] += sz[ne];
  }
  for (int i = 1; i < n; i++) nap[i] = false;
  int cur = 0;
  for (int ne : adj[c]) {
    if (ne == p)
      cur = n - sz[c];
    else
      cur = sz[ne];
    for (int i = n; i > -1; i--)
      if (i - cur >= 0) nap[i] |= nap[i - cur];
  }
  for (int i = 0; i < n; i++) {
    ans[i] |= nap[i];
  }
  return;
}
int main() {
  nap[0] = true;
  n = iin();
  for (int i = 0; i < n - 1; i++) {
    int a = iin() - 1, b = iin() - 1;
    adj[a].push_back(b), adj[b].push_back(a);
  }
  dfs(0, -1);
  int anss = 0;
  for (int i = 1; i < n - 1; i++)
    if (ans[i]) anss++;
  printf("%d\n", anss);
  for (int i = 1; i < n - 1; i++)
    if (ans[i]) printf("%d %d \n", i, n - 1 - i);
  return 0;
}
