#include <bits/stdc++.h>
using namespace std;
const int N = 5000 + 100;
const long long int base = 313;
const long long int mod = 1e9 + 7;
const long long int inf = 1e9;
bitset<N> dp, ans;
int par[N], sz[N], n;
vector<int> adj[N];
void dfs(int u) {
  sz[u] = 1;
  for (auto x : adj[u]) {
    if (x != par[u]) {
      par[x] = u;
      dfs(x);
      sz[u] += sz[x];
    }
  }
  dp.reset();
  dp[0] = 1;
  for (auto x : adj[u]) {
    if (x != par[u]) {
      dp |= (dp << sz[x]);
    }
  }
  dp |= (dp << (n - sz[u]));
  ans |= dp;
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  dfs(0);
  cout << ans.count() - 2 << endl;
  for (int i = 1; i < n - 1; i++) {
    if (ans[i]) cout << i << ' ' << n - i - 1 << endl;
  }
  return 0;
}
