#include <bits/stdc++.h>
using namespace std;
void fastio() {
  cin.tie(nullptr);
  cin.sync_with_stdio(false);
}
using LL = long long;
using LD = long double;
const LL MOD = 998244353;
const LL INF = LLONG_MAX;
const LL N = 201;
void knapsack(vector<LL> &a, vector<LL> &a_size) {
  LL n = a_size.size(), m = a.size();
  vector<vector<int>> dp(m + 1, vector<int>(n + 1, 0));
  dp[0][0] = 1;
  for (LL i = 1; i <= m; ++i) {
    for (LL j = 0; j <= n; ++j) {
      if (dp[i - 1][j] == 1) {
        dp[i][j] = 1;
      } else if (j >= a[i - 1] && dp[i - 1][j - a[i - 1]] == 1) {
        dp[i][j] = 1;
      }
    }
  }
  for (LL i = 1; i < n - 1; ++i) {
    a_size[i] |= dp[m][i];
  }
}
void dfs(LL st, LL prev, vector<vector<LL>> &adj, vector<LL> &size,
         vector<LL> &a_size) {
  LL sz = 1, n = adj.size();
  vector<LL> a;
  for (auto e : adj[st]) {
    if (e != prev) {
      dfs(e, st, adj, size, a_size);
      sz += size[e];
      a.push_back(size[e]);
    }
  }
  if (n - sz > 0) {
    a.push_back(n - sz);
  }
  if (a.size() > 1) {
    knapsack(a, a_size);
  }
  size[st] = sz;
}
int main() {
  fastio();
  LL n;
  cin >> n;
  vector<vector<LL>> adj(n);
  for (LL i = 0; i < n - 1; ++i) {
    LL u, v;
    cin >> u >> v;
    u--;
    v--;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  vector<LL> size(n);
  vector<LL> a_size(n, 0);
  dfs(0, 0, adj, size, a_size);
  LL cnt = accumulate(a_size.begin(), a_size.end(), 0LL);
  cout << cnt << "\n";
  for (LL i = 0; i < n; ++i) {
    if (a_size[i]) {
      cout << i << " " << n - 1 - i << "\n";
    }
  }
}
