#include <bits/stdc++.h>
using namespace std;
int b[312345], ll, rr, tt, i, j, c[11456], ans, dp[5001][5006], a[311567], inf;
int x, m, n, r, s, t, k, l, y, z, son[234567];
vector<int> p[456345], qq;
vector<int> q, w;
void dfs(int x, int y) {
  son[x] = 1;
  int j;
  dp[x][0] = 1;
  for (auto u : p[x]) {
    if (u == y) continue;
    dfs(u, x);
    son[x] += son[u];
    for (j = n; j >= 0; j--) {
      if (dp[x][j] != 0) {
        dp[x][j + son[u]] = 1;
      }
    }
  }
  for (j = son[x]; j >= 0; j--) {
    if (dp[x][j] != 0) {
      dp[x][n - son[x] + j] = 1;
    }
  }
  for (j = 1; j <= n; j++) {
    if (dp[x][j] > 0) c[j] = 1;
  }
}
int main() {
  cin >> n;
  for (i = 1; i < n; i++) {
    cin >> x >> y;
    p[x].push_back(y);
    p[y].push_back(x);
  }
  dfs(1, 0);
  for (i = 1; i < n - 1; i++) {
    if (c[i] > 0) {
      ans++;
    }
  }
  cout << ans << endl;
  for (i = 1; i < n - 1; i++) {
    if (c[i] != 0) {
      cout << i << ' ' << n - i - 1 << endl;
    }
  }
  return 0;
}
