#include <bits/stdc++.h>
using namespace std;
constexpr int N = 5e5 + 5;
int n, c[N], p[N];
bool vis[N], jo[N];
vector<int> edges[N];
int dfs(int id, int par = -1) {
  vis[id] = 1;
  c[id] = 1;
  p[id] = par;
  for (int v : edges[id]) {
    if (!vis[v]) c[id] += dfs(v, id);
  }
  return c[id];
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  for (int i = 0, u, v; i < n - 1; i++) {
    cin >> u >> v;
    edges[u - 1].push_back(v - 1);
    edges[v - 1].push_back(u - 1);
  }
  dfs(0);
  for (int i = 0; i < n; i++) {
    set<int> s;
    s.insert(0);
    for (int v : edges[i]) {
      if (v == p[i]) continue;
      queue<int> q;
      for (auto x : s) q.push(x + c[v]);
      while (!q.empty()) {
        s.insert(q.front());
        q.pop();
      }
    }
    queue<int> q;
    for (auto x : s) q.push(x + n - c[i]);
    while (!q.empty()) {
      s.insert(q.front());
      q.pop();
    }
    for (auto x : s) jo[x] = 1;
  }
  cout << count(jo, jo + n - 1, 1) - 1 << '\n';
  for (int i = 1; i < n - 1; i++) {
    if (jo[i]) cout << i << ' ' << n - 1 - i << '\n';
  }
}
