#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> adj[5005];
int sub[5005];
bitset<5005> ans;
void dfs(int u, int p) {
  sub[u] = 1;
  bitset<5005> nodo;
  nodo.set(0);
  nodo[0] = 1;
  for (int v : adj[u]) {
    if (v == p) continue;
    dfs(v, u);
    int sz = sub[v];
    nodo |= (nodo << sz);
    sub[u] += sz;
  }
  if (u != 1) {
    nodo |= (nodo << (n - sub[u]));
  }
  ans |= nodo;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i < n; i++) {
    int u, v;
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  dfs(1, 0);
  cout << ans.count() - 2 << '\n';
  for (int i = 1; i < n - 1; i++) {
    if (ans[i]) {
      cout << i << " " << n - i - 1 << '\n';
    }
  }
  return 0;
}
