#include <bits/stdc++.h>
using namespace std;
template <typename... T>
inline void inp(T&... args) {
  ((cin >> args), ...);
}
template <typename T>
inline istream& operator>>(istream& in, vector<T>& a) {
  for (auto& x : a) in >> x;
  return in;
}
template <typename T, typename U>
inline istream& operator>>(istream& in, pair<T, U>& a) {
  in >> a.first >> a.second;
  return in;
}
using graph = vector<vector<long long int>>;
graph g;
long long int n, m;
vector<long long int> ss;
set<pair<long long int, long long int>> ans;
void clearAll(long long int N) {
  N++;
  g.resize(N);
  ss.resize(N);
  ans.clear();
  for (long long int i = (0); i < (N); i += (1)) {
    g[i].clear();
    ss[i] = 1;
  }
}
void dfs1(long long int u, long long int p) {
  for (long long int v : g[u]) {
    if (v != p) {
      dfs1(v, u);
      ss[u] += ss[v];
    }
  }
}
void its_dp(vector<long long int>& a) {
  long long int nn = a.size();
  long long int mm = n;
  long long int dp[nn + 1][mm + 1];
  memset(dp, 0, sizeof(dp));
  for (long long int i = (0); i < (nn); i += (1)) {
    dp[i][a[i]] = 1;
    dp[i][0] = 1;
    for (long long int j = (0); j < (mm); j += (1)) {
      if (i >= 1) {
        if (dp[i - 1][j] || (j >= a[i] and dp[i - 1][j - a[i]])) {
          dp[i][j] = 1;
        }
      }
    }
  }
  for (long long int i = (0); i < (mm); i += (1)) {
    if (dp[nn - 1][i]) {
      long long int x = i;
      long long int y = n - 1 - x;
      if (x > 0 and y > 0) {
        ans.emplace(x, y);
        ans.emplace(y, x);
      }
    }
  }
}
void dfs2(long long int u, long long int p) {
  vector<long long int> sz;
  for (long long int v : g[u]) {
    if (v != p) {
      sz.emplace_back(ss[v]);
      dfs2(v, u);
    } else {
      sz.emplace_back(ss[1] - ss[u]);
    }
  }
  11;
  its_dp(sz);
}
void solve(int& T) {
  cin >> n;
  clearAll(n);
  m = n - 1;
  for (long long int i = (0); i < (m); i += (1)) {
    long long int x, y;
    cin >> x >> y;
    g[x].emplace_back(y);
    g[y].emplace_back(x);
  }
  dfs1(1, -1);
  dfs2(1, -1);
  cout << ans.size() << '\n';
  for (auto& X : ans) {
    cout << X.first << " " << X.second << '\n';
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int t = 1;
  for (int i = 1; i <= t; i++) {
    if (0) cerr << "Case #" << i << "\n";
    solve(i);
  }
  return 0;
}
