#include <bits/stdc++.h>
using namespace std;
long long mod = 10e9 + 7;
long long gcd(long long a, long long b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
long long modularExp(long long x, long long n, long long mod) {
  long long result = 1;
  while (n > 0) {
    if (n % 2 == 1) result = (result * x) % mod;
    x = ((x % mod) * (x % mod)) % mod;
    n = n / 2;
  }
  return (result) % mod;
}
bool isPrime(long long n) {
  for (long long i = 2; i * i <= n; i++)
    if (n % i == 0) return false;
  return true;
}
vector<int> v[100005];
vector<int> dp(100005, 0);
int dfs(int node, int par) {
  int res = 1;
  for (auto it : v[node]) {
    if (it != par) res += dfs(it, node);
  }
  return res;
}
void solve() {
  int n;
  cin >> n;
  vector<int> deg(n + 1);
  for (int i = 0; i < n - 1; i++) {
    int x, y;
    cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x);
    deg[x]++;
    deg[y]++;
  }
  for (int i = 1; i <= n; i++) {
    if (deg[i] >= 2) {
      bitset<5001> bit;
      bit[0] = 1;
      for (auto it : v[i]) {
        int sz = dfs(it, i);
        bit |= (bit << sz);
      }
      for (int j = 1; j < n - 1; j++)
        if (bit[j]) dp[j] = 1;
    }
  }
  int total = n - 1;
  vector<pair<int, int> > pt;
  for (int i = 1; i <= total - 1; i++) {
    if (dp[i]) pt.push_back({i, total - i});
  }
  int res = pt.size();
  cout << res << "\n";
  for (auto it : pt) cout << it.first << " " << it.second << "\n";
}
int main() {
  int t;
  t = 1;
  while (t--) solve();
}
