#include <bits/stdc++.h>
using namespace std;
const double pi = 3.14159265359;
const int MAX = 1e6 + 2;
const long long int inf = 1e18;
const int N = 1010;
const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
const long long int mod = 1000000007;
inline long long int add(long long int a, long long int b) {
  a += b;
  if (a >= mod) a -= mod;
  return a;
}
inline long long int mul(long long int a, long long int b) {
  return (((a + mod) % mod) * (b + mod) % mod) % mod;
}
inline long long int power(long long int a, long long int b) {
  long long int rt = 1;
  while (b > 0) {
    if (b & 1) rt = mul(rt, a);
    a = mul(a, a);
    b >>= 1;
  }
  return rt;
}
inline long long int modInverse(long long int n, long long int p) {
  return power(n, p - 2) % p;
}
void stArt() {}
void eNd() {}
long long int i, j, k, l, m, r, n;
long long int a[MAX], dp[5 * N][5 * N];
vector<long long int> adj[MAX];
long long int sz[MAX];
void dfs(long long int v, long long int par = -1) {
  sz[v] = 1;
  dp[v][0] = 1;
  for (auto u : adj[v]) {
    if (u == par) continue;
    dfs(u, v);
    sz[v] += sz[u];
    for (i = n - 1; i >= 0; i--)
      if (dp[v][i]) dp[v][i + sz[u]] = 1;
  }
  k = n - sz[v];
  for (i = n - 1; i >= 0; i--)
    if (dp[v][i]) dp[v][i + k] = 1;
  for (i = 1; i < n - 1; i++)
    if (dp[v][i]) a[i] = 1;
}
int main() {
  stArt();
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (i = 0; i < n - 1; i++) {
    cin >> l >> r;
    adj[l].emplace_back(r);
    adj[r].emplace_back(l);
  }
  dfs(1);
  vector<pair<long long int, long long int> > ans;
  for (i = 1; i < n - 1; i++) {
    if (a[i]) ans.emplace_back(i, n - i - 1);
  }
  cout << ans.size() << "\n";
  for (auto x : ans) cout << x.first << ' ' << x.second << "\n";
  eNd();
  return 0;
}
