#include <bits/stdc++.h>
using namespace std;
void oj() {}
vector<long long> v[200005], sub(200005);
set<pair<long long, long long>> s;
long long n;
void func(vector<long long> v) {
  long long nn = v.size(), sum = 0;
  for (auto x : v) sum += x;
  bool dp[nn + 1][sum + 1];
  memset(dp, false, sizeof(dp));
  for (long long i = 0; i <= nn; i++) dp[i][0] = true;
  for (long long i = 1; i <= nn; i++) {
    for (long long j = 1; j <= sum; j++) {
      if (v[i - 1] <= j)
        dp[i][j] = dp[i - 1][j] || dp[i - 1][j - v[i - 1]];
      else
        dp[i][j] = dp[i - 1][j];
    }
  }
  for (long long i = 1; i < sum; i++) {
    if (dp[nn][i]) {
      s.insert({i, n - i - 1});
      s.insert({n - i - 1, i});
    }
  }
}
void dfs(long long x, long long par) {
  sub[x] = 1;
  for (auto el : v[x]) {
    if (el != par) {
      dfs(el, x);
      sub[x] += sub[el];
    }
  }
}
void solve() {
  cin >> n;
  for (long long i = 0; i < n - 1; i++) {
    long long x, y;
    cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  dfs(1, 0);
  for (long long x = 1; x <= n; x++) {
    if (v[x].size() == 1) continue;
    vector<long long> temp;
    for (auto el : v[x])
      if (sub[el] > sub[x])
        temp.push_back(n - sub[x]);
      else
        temp.push_back(sub[el]);
    func(temp);
  }
  cout << s.size() << endl;
  for (auto x : s) cout << x.first << " " << x.second << endl;
}
signed main() {
  oj();
  ios::sync_with_stdio(0);
  cin.tie(0);
  ;
  solve();
  return 0;
}
