#include <bits/stdc++.h>
using namespace std;
const int N = 5005;
int n;
vector<int> ar[N];
bool possible[N], local[N];
int dfs(int node, int par) {
  int s = 1;
  vector<int> sizes;
  for (int ch : ar[node]) {
    if (ch != par) {
      int tmp = dfs(ch, node);
      s += tmp;
      sizes.push_back(tmp);
    }
  }
  if (!sizes.empty()) {
    if (par != 0) {
      sizes.push_back(n - s);
    }
    memset(local, 0, sizeof(local));
    local[0] = 1;
    for (int x : sizes) {
      for (int i = n - x; i >= 0; i--) {
        if (local[i] == 1) local[i + x] = 1, possible[i + x] = 1;
      }
    }
  }
  return s;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n;
  int x, y;
  for (int i = 1; i < n; i++) {
    cin >> x >> y;
    ar[x].push_back(y);
    ar[y].push_back(x);
  }
  int k = dfs(1, 0);
  vector<int> ans;
  for (int i = 1; i <= n - 2; i++) {
    if (possible[i]) {
      ans.push_back(i);
    }
  }
  cout << ans.size() << endl;
  for (int i : ans) {
    cout << i << " " << n - i - 1 << endl;
  }
  return 0;
}
