#include <bits/stdc++.h>
using namespace std;
const int N = 2000005;
const int mod = 1e9 + 7;
vector<int> adj[N];
vector<int> vis;
vector<int> sz;
int n;
set<int> ans;
void dfs(int x) {
  if (vis[x]) return;
  vis[x] = 1;
  sz[x]++;
  for (auto v : adj[x]) {
    if (vis[v]) continue;
    dfs(v);
    sz[x] += sz[v];
  }
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  vis.resize(n + 1);
  sz.resize(n + 1);
  for (int i = 2; i <= n; i++) {
    int u, v;
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  for (int i = 1; i <= n; i++) {
    if (adj[i].size() == 1) continue;
    dfs(i);
    vector<int> dp(n + 1, 0);
    dp[0] = 1;
    vector<int> temp;
    for (auto v : adj[i]) {
      temp.push_back(sz[v]);
    }
    vector<int> temp2;
    for (auto v : temp) {
      for (int j = n; j >= v; --j) {
        if (dp[j - v]) dp[j] = 1;
      }
    }
    for (int j = 1; j <= n; j++) {
      if (dp[j]) {
        if ((j > 0) && (j < n - 1)) ans.insert(j);
      }
    }
    for (int j = 1; j <= n; j++) {
      sz[j] = 0;
      vis[j] = 0;
    }
  }
  cout << ans.size() << "\n";
  for (auto v : ans) {
    if ((v > 0) && (v < (n - 1))) cout << v << " " << n - 1 - v << "\n";
  }
}
