#include <bits/stdc++.h>
using namespace std;
vector<int64_t> v[5005];
int64_t sz[5005];
bitset<5005> cansplit;
bitset<5005> dp;
int64_t mx;
void dfs(int64_t x, int64_t p) {
  sz[x] = 1;
  for (int64_t i : v[x])
    if (i != p) {
      dfs(i, x);
      sz[x] += sz[i];
    }
}
void calc(int64_t x, int64_t p, int64_t totsz) {
  vector<int64_t> vv;
  for (int64_t i : v[x])
    if (i != p) {
      vv.push_back(sz[i]);
    }
  if (x != p) {
    vv.push_back(totsz - sz[x]);
  }
  dp.reset();
  dp[0] = 1;
  for (int64_t i : vv) {
    dp = dp | (dp << i);
  }
  cansplit = cansplit | dp;
  for (int64_t i : v[x])
    if (i != p) {
      calc(i, x, totsz);
    }
}
int32_t main() {
  {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
  };
  int64_t n, a, b;
  cin >> n;
  for (int64_t i = 1; i < n; i++) {
    cin >> a >> b;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  dfs(1, 1);
  calc(1, 1, sz[1]);
  cout << (int64_t)(cansplit.count()) - 2 << '\n';
  for (int64_t i = 1; i < n - 1; i++)
    if (cansplit[i]) {
      cout << i << ' ' << n - i - 1 << '\n';
    }
  return 0;
}
