|시간 제한||메모리 제한||제출||정답||맞은 사람||정답 비율|
|2 초||64 MB||11||6||6||54.545%|
Once upon a time in a far away kingdom there were 2 kings that ruled their realm together. This kingdom has N towns which are connected with undirected roads. Each king owns a disjoint subset of these roads, and together they own all of the roads. You know that each king owns exactly N - 1 roads such that it is possible to reach any town from other town using these roads. There might be multiple roads between the same pair of towns.
In this story there is also an Evil Lord that one day decides to conquer the kingdom. It's a well known strategy to divide a kingdom to more easily conquer it. So the Evil Lord is interested in the minimum number of roads he has to destroy such that there exists a pair of towns X and Y with the property that it is impossible to reach Y from X. He is also interested in the number of ways to delete the minimum number of roads.
Your task is to find these 2 numbers, the minimum roads the Evil Lord has to destroy to divide the kingdom and the number of ways he can do this. As the number of ways to delete roads may be very big, output it modulo 1.000.000.007(109 + 7).
The first line of the input contains one integer N (2 ≤ N ≤ 105).
Each of the next N-1 lines contains 2 integers ai, bi, which means that first king owns the road between cities ai and bi (1 ≤ ai, bi ≤ N).
Each of the next N-1 lines contains 2 integers ai, bi, which means that second king owns the road between cities ai and bi (1 ≤ ai, bi ≤ N).
Print two integers - the minimum number of roads you need to destroy in order to disconnect the graph and number of ways to do this modulo 109 + 7.
5 1 3 3 5 2 3 1 4 1 4 4 5 2 5 3 5
2 1 2 1 2