#include <bits/stdc++.h>
using namespace std;
int dfs(int p, int root, vector<set<int> >& adj, vector<int>& nc) {
  if (p != -1) {
    adj[root].erase(adj[root].find(p));
  }
  set<int>::const_iterator it;
  for (it = adj[root].begin(); it != adj[root].end(); it++) {
    nc[root] += dfs(root, *it, adj, nc);
  }
  nc[root]++;
  return nc[root];
}
int main() {
  int n;
  cin >> n;
  vector<set<int> > adj(n, set<int>());
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    adj[x - 1].insert(y - 1);
    adj[y - 1].insert(x - 1);
  }
  vector<int> nc(n, 0);
  dfs(-1, 0, adj, nc);
  set<int> ans;
  set<int>::iterator ii;
  vector<int>::iterator it;
  for (int i = 0; i < n; i++) {
    if (i == 0 and adj[i].size() == 1) {
      continue;
    }
    if (i > 0 and adj[i].size() == 0) {
      continue;
    }
    vector<int> v;
    for (ii = adj[i].begin(); ii != adj[i].end(); ii++) {
      v.push_back(nc[*ii]);
    }
    if (i > 0) {
      int sum = 0;
      for (it = v.begin(); it != v.end(); it++) {
        sum += *it;
      }
      v.push_back(n - 1 - sum);
    }
    set<int> r[2];
    r[0].insert(0);
    r[1].insert(0);
    int last = 0, next = 1;
    for (it = v.begin(); it != v.end(); it++) {
      for (ii = r[last].begin(); ii != r[last].end(); ii++) {
        r[next].insert(*ii);
        r[next].insert(*ii + *it);
      }
      swap(last, next);
    }
    for (ii = r[last].begin(); ii != r[last].end(); ii++) {
      if (*ii > 0 and n - 1 - *ii > 0) {
        ans.insert(*ii);
        ans.insert(n - 1 - *ii);
      }
    }
  }
  cout << ans.size() << endl;
  for (ii = ans.begin(); ii != ans.end(); ii++) {
    cout << *ii << " " << n - 1 - *ii << endl;
  }
  return 0;
}
