#include <bits/stdc++.h>
using namespace std;
const int N = 6e3;
const long long INF = 1e18;
int n;
vector<int> g[N];
int size[N], par[N];
void build(int x, int p = -1) {
  par[x] = p;
  size[x] = 1;
  for (int i = int(0); i <= int(g[x].size() - 1); ++i) {
    int to = g[x][i];
    if (to == p) continue;
    build(to, x);
    size[x] += size[to];
  }
}
int sz, a[N];
int d[N];
set<int> res;
void knapsack(int x) {
  memset(d, 0, sizeof(d));
  sz = 0;
  for (auto to : g[x])
    if (to != par[x]) a[++sz] = size[to];
  if (x > 1) a[++sz] = n - size[x];
  d[0] = 1;
  for (int i = int(1); i <= int(sz); ++i)
    for (int j = int(n); j >= int(a[i]); --j) d[j] |= d[j - a[i]];
  for (int i = int(1); i <= int(n - 2); ++i)
    if (d[i]) res.insert(i);
}
int main() {
  ios_base ::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = int(1); i <= int(n - 1); ++i) {
    int f, t;
    cin >> f >> t;
    g[f].push_back(t);
    g[t].push_back(f);
  }
  build(1);
  for (int i = int(1); i <= int(n); ++i) knapsack(i);
  cout << res.size() << "\n";
  for (auto x : res) cout << x << " " << n - 1 - x << "\n";
  return 0;
}
