#include <bits/stdc++.h>
using namespace std;
int N;
int reach[5000 + 1];
list<pair<int, int> > adj[5000];
int child[5000];
set<int> res;
void foo(int s) {
  memset(reach, 0, sizeof reach);
  reach[0] = 1;
  int upperB = 0;
  int counter = 1;
  for (list<pair<int, int> >::iterator it = adj[s].begin(); it != adj[s].end();
       it++) {
    counter++;
    for (int i = 0; i <= upperB; i++)
      if (reach[i] && reach[i] < counter) {
        if (reach[i + it->second])
          reach[i + it->second] = min(reach[i + it->second], counter);
        else
          reach[i + it->second] = counter;
        upperB = min(N / 2, max(upperB, i + it->second));
      }
  }
  for (int i = 1; i <= N / 2 - (N % 2 == 0); i++)
    if (reach[i]) {
      res.insert(i);
      if (i != N - i - 1) res.insert(N - i - 1);
    }
}
int getSub(int s, int a) {
  if (child[s] == 1) return 1;
  int tot = 0;
  for (list<pair<int, int> >::iterator it = adj[s].begin(); it != adj[s].end();
       it++)
    if (it->first != a) {
      if (!it->second) it->second = getSub(it->first, s);
      tot += it->second;
    }
  return tot + 1;
}
int main() {
  scanf("%d", &N);
  int i, a, b;
  for (i = 0; i < N - 1; i++) {
    scanf("%d %d", &a, &b);
    adj[a - 1].push_back(make_pair(b - 1, 0));
    adj[b - 1].push_back(make_pair(a - 1, 0));
    child[a - 1]++;
    child[b - 1]++;
  }
  for (i = 0; i < N; i++)
    for (list<pair<int, int> >::iterator it = adj[i].begin();
         it != adj[i].end(); it++) {
      if (!it->second) it->second = getSub(it->first, i);
    }
  for (i = 0; i < N; i++)
    if (child[i] > 1) {
      foo(i);
    }
  printf("%d\n", res.size());
  for (set<int>::iterator it = res.begin(); it != res.end(); it++)
    printf("%d %d\n", *it, N - 1 - *it);
  return 0;
}

### Prompt

Your challenge is to write a CPP solution to the following problem:

Сity N. has a huge problem with roads, food and IT-infrastructure. In total the city has n junctions, some pairs of them are connected by bidirectional roads. The road network consists of n - 1 roads, you can get from any junction to any other one by these roads. Yes, you're right — the road network forms an undirected tree.

Recently, the Mayor came up with a way that eliminates the problems with the food and the IT-infrastructure at the same time! He decided to put at the city junctions restaurants of two well-known cafe networks for IT professionals: "iMac D0naldz" and "Burger Bing". Since the network owners are not friends, it is strictly prohibited to place two restaurants of different networks on neighboring junctions. There are other requirements. Here's the full list:

  * each junction must have at most one restaurant; 
  * each restaurant belongs either to "iMac D0naldz", or to "Burger Bing"; 
  * each network should build at least one restaurant; 
  * there is no pair of junctions that are connected by a road and contains restaurants of different networks. 



The Mayor is going to take a large tax from each restaurant, so he is interested in making the total number of the restaurants as large as possible.

Help the Mayor to analyze the situation. Find all such pairs of (a, b) that a restaurants can belong to "iMac D0naldz", b restaurants can belong to "Burger Bing", and the sum of a + b is as large as possible.

Input

The first input line contains integer n (3 ≤ n ≤ 5000) — the number of junctions in the city. Next n - 1 lines list all roads one per line. Each road is given as a pair of integers xi, yi (1 ≤ xi, yi ≤ n) — the indexes of connected junctions. Consider the junctions indexed from 1 to n.

It is guaranteed that the given road network is represented by an undirected tree with n vertexes.

Output

Print on the first line integer z — the number of sought pairs. Then print all sought pairs (a, b) in the order of increasing of the first component a.

Examples

Input

5
1 2
2 3
3 4
4 5


Output

3
1 3
2 2
3 1


Input

10
1 2
2 3
3 4
5 6
6 7
7 4
8 9
9 10
10 4


Output

6
1 8
2 7
3 6
6 3
7 2
8 1

Note

The figure below shows the answers to the first test case. The junctions with "iMac D0naldz" restaurants are marked red and "Burger Bing" restaurants are marked blue.

<image>

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int N;
int reach[5000 + 1];
list<pair<int, int> > adj[5000];
int child[5000];
set<int> res;
void foo(int s) {
  memset(reach, 0, sizeof reach);
  reach[0] = 1;
  int upperB = 0;
  int counter = 1;
  for (list<pair<int, int> >::iterator it = adj[s].begin(); it != adj[s].end();
       it++) {
    counter++;
    for (int i = 0; i <= upperB; i++)
      if (reach[i] && reach[i] < counter) {
        if (reach[i + it->second])
          reach[i + it->second] = min(reach[i + it->second], counter);
        else
          reach[i + it->second] = counter;
        upperB = min(N / 2, max(upperB, i + it->second));
      }
  }
  for (int i = 1; i <= N / 2 - (N % 2 == 0); i++)
    if (reach[i]) {
      res.insert(i);
      if (i != N - i - 1) res.insert(N - i - 1);
    }
}
int getSub(int s, int a) {
  if (child[s] == 1) return 1;
  int tot = 0;
  for (list<pair<int, int> >::iterator it = adj[s].begin(); it != adj[s].end();
       it++)
    if (it->first != a) {
      if (!it->second) it->second = getSub(it->first, s);
      tot += it->second;
    }
  return tot + 1;
}
int main() {
  scanf("%d", &N);
  int i, a, b;
  for (i = 0; i < N - 1; i++) {
    scanf("%d %d", &a, &b);
    adj[a - 1].push_back(make_pair(b - 1, 0));
    adj[b - 1].push_back(make_pair(a - 1, 0));
    child[a - 1]++;
    child[b - 1]++;
  }
  for (i = 0; i < N; i++)
    for (list<pair<int, int> >::iterator it = adj[i].begin();
         it != adj[i].end(); it++) {
      if (!it->second) it->second = getSub(it->first, i);
    }
  for (i = 0; i < N; i++)
    if (child[i] > 1) {
      foo(i);
    }
  printf("%d\n", res.size());
  for (set<int>::iterator it = res.begin(); it != res.end(); it++)
    printf("%d %d\n", *it, N - 1 - *it);
  return 0;
}

```