#include <bits/stdc++.h>
using namespace std;
void _print(long long int t) { cerr << t; }
void _print(int t) { cerr << t; }
void _print(string t) { cerr << t; }
void _print(char t) { cerr << t; }
void _print(double t) { cerr << t; }
template <class T, class V>
void _print(pair<T, V> p) {
  cerr << "{";
  _print(p.first);
  cerr << ",";
  _print(p.second);
  cerr << "}";
}
template <class T>
void _print(vector<T> v) {
  cerr << "[ ";
  for (T i : v) {
    _print(i);
    cerr << " ";
  }
  cerr << "]";
}
template <class T>
void _print(set<T> v) {
  cerr << "[ ";
  for (T i : v) {
    _print(i);
    cerr << " ";
  }
  cerr << "]";
}
template <class T>
void _print(multiset<T> v) {
  cerr << "[ ";
  for (T i : v) {
    _print(i);
    cerr << " ";
  }
  cerr << "]";
}
template <class T, class V>
void _print(map<T, V> v) {
  cerr << "[ ";
  for (auto i : v) {
    _print(i);
    cerr << " ";
  }
  cerr << "]";
}
long long int powr(long long int a, long long int b) {
  if (b == 0) return 1;
  long long int hlf = powr(a, b / 2);
  hlf = (hlf * hlf) % 1000000007;
  if (b % 2) return (hlf * a) % 1000000007;
  return hlf;
}
void extentded_eucledian(long long int a, long long int b, long long int &ex,
                         long long int &ey) {
  if (b == 0) {
    ex = 1;
    ey = 0;
    return;
  }
  extentded_eucledian(b, a % b, ex, ey);
  swap(ex, ey);
  ey -= (a / b) * ex;
}
bool decend(const pair<int, int> &a, const pair<int, int> &b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first > b.first;
  }
}
set<pair<long long int, long long int>> s1;
vector<vector<long long int>> adj;
vector<long long int> dp;
long long int n;
long long int dfs(long long int root, long long int p) {
  bitset<5005> b1(1);
  for (long long int x : adj[root]) {
    if (x == p) continue;
    dp[root] += dfs(x, root);
    b1 |= (b1 << dp[x]);
  }
  for (long long int i = 1; i <= 5000; i++) {
    if (b1[i] == 1 && i < n - 1) {
      s1.insert({i, n - 1 - i});
      s1.insert({n - 1 - i, i});
    }
  }
  dp[root] += 1;
  return dp[root];
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  std::cout << std::fixed << std::setprecision(0);
  long long int t = 1;
  while (t--) {
    cin >> n;
    adj = vector<vector<long long int>>(n + 1);
    dp = vector<long long int>(n + 1, 0);
    for (int i = 0; i < n - 1; i++) {
      long long int a, b;
      cin >> a >> b;
      adj[a].push_back(b);
      adj[b].push_back(a);
    }
    dfs(1, 0);
    cout << s1.size() << "\n";
    for (auto x : s1) {
      cout << x.first << " " << x.second << "\n";
    }
  }
  return 0;
}
