#include <bits/stdc++.h>
using namespace std;
vector<int> G[8192];
int p[8192];
int sum[8192];
bool sol[8192];
bool temp[8192];
int dfs1(int x, int pa);
int main() {
  int n;
  while (cin >> n) {
    for (int i = 1; i < n; i++) {
      int a, b;
      cin >> a >> b;
      a--;
      b--;
      G[a].push_back(b);
      G[b].push_back(a);
    }
    dfs1(0, 0);
    for (int i = 0; i < n; i++) {
      memset(temp, false, sizeof(temp));
      temp[0] = 1;
      for (int j = 0; j < G[i].size(); j++) {
        if (p[i] == G[i][j]) continue;
        for (int k = 8192 - 1; k >= sum[G[i][j]]; k--)
          temp[k] |= temp[k - sum[G[i][j]]];
      }
      for (int k = 8192 - 1; k >= (n - sum[i]); k--)
        temp[k] |= temp[k - (n - sum[i])];
      for (int j = 0; j < 8192; j++) sol[j] |= temp[j];
    }
    int cnt = 0;
    for (int i = 1; i < n - 1; i++)
      if (sol[i]) cnt++;
    cout << cnt << endl;
    for (int i = 1; i < n - 1; i++) {
      if (sol[i]) cout << i << " " << n - 1 - i << endl;
    }
  }
  return 0;
}
int dfs1(int x, int pa) {
  int s = 0;
  for (int i = 0; i < G[x].size(); i++) {
    int y = G[x][i];
    if (y != pa) {
      p[y] = x;
      s += dfs1(y, x);
    }
  }
  return sum[x] = s + 1;
}
