#include <bits/stdc++.h>
using namespace std;
int n;
struct node {
  vector<int> e;
  vector<int> c;
  bool vis = false;
};
vector<node> g;
vector<bool> ans;
int dfs(int start) {
  g[start].vis = true;
  int par = -1;
  int child = 0;
  for (int i = 0; i < g[start].e.size(); ++i) {
    int nex = g[start].e[i];
    if (g[nex].vis) {
      par = i;
    } else {
      g[start].c[i] = dfs(nex);
      child += g[start].c[i];
    }
  }
  g[start].c[par] = n - child - 1;
  return child + 1;
}
void do_rest(vector<int>& cur) {
  if (cur.size() < 2) {
    return;
  }
  vector<bool> tmp(n + 1, false);
  tmp[0] = true;
  for (int i = 0; i < cur.size(); ++i) {
    vector<int> run;
    for (int j = 0; j < tmp.size(); ++j) {
      if (j - cur[i] >= 0 && tmp[j - cur[i]]) {
        run.push_back(j);
      }
    }
    for (int j = 0; j < run.size(); ++j) {
      tmp[run[j]] = true;
    }
  }
  for (int i = 0; i < tmp.size(); ++i) {
    if (tmp[i]) {
      ans[i] = tmp[i];
    }
  }
}
int main() {
  cin >> n;
  ans.resize(n, false);
  g.resize(n);
  int a, b;
  for (int i = 0; i < n - 1; ++i) {
    cin >> a >> b;
    a--;
    b--;
    g[a].e.push_back(b);
    g[a].c.push_back(0);
    g[b].e.push_back(a);
    g[b].c.push_back(0);
  }
  dfs(0);
  for (int i = 0; i < n; ++i) {
    do_rest(g[i].c);
  }
  int c = 0;
  for (int i = 1; i < n - 1; ++i) {
    if (ans[i]) {
      c++;
    }
  }
  cout << c << "\n";
  for (int i = 1; i < n - 1; ++i) {
    if (ans[i]) {
      cout << i << " " << n - i - 1 << "\n";
    }
  }
}
