Amin has gone to Postun for vacation. One of the tourist attractions of Postun is its…
- User
Amin has gone to Postun for vacation. One of the tourist attractions of Postun is its large and beautiful squares. The city squares are connected to each other by a number of streets.
Amin can take a taxi from Uber or Snap to move between squares in the city! Each of these two companies has covered a set of streets in the city, so that with the streets covered by each company alone, you can go from any square to any other square with a unique route. Also, there is no street that is covered by both Uber and Snap.
Amin wants to go around the squares of the city. He performs round-robin operations in such a way that he starts from an arbitrary square, does not cross any street more than once, and finally returns to the first square. In each movement, he takes a taxi from one of the two companies and goes from one end of a street that is covered by that company to the other end of that street.
Because the cost of using Uber taxis is very high, Amin can use them at most twice, but he can use Snap taxis as many times as he wants. On the other hand, Uber taxis are far more luxurious than Snap taxis, and as a result, he intends to use twice as much as he can pay for Uber taxis. So a round trip is profitable from Amin's point of view if and only if Uber taxis are used exactly twice during it.
Amin considers two rounds as different if in one of them we cross a street that we will not cross in the other round. Can you count the number of different laps Amin can do by taking the routes covered by Uber and the routes covered by Snap?
input In the first line of input number n n is the number of Poston fields. in n
1 n−1 next line, two natural numbers in each line v s , i v s.i and u s , i u s.i It is said that it shows that the street connecting those two squares is covered by SNAP. in n
1 n−1 next line, two natural numbers in each line v u , i v u, i and u u , i u u, i It is said that it shows that the street connecting those two squares is covered by Uber. There is at most one street between both squares. With the taxis covered by each company, you can get from any square to any other square.
4 ≤ n ≤ 100
000 4≤n≤100 000 1 ≤ v s , i , u s , i ≤ n 1≤v s.i ,u s.i ≤n 1 ≤ v u , i , u u , i ≤ n 1≤v u, i ,u u, i ≤n
output On the only output line, print the number of rounds of economical rounds in your post.
Sub-issues Constraint score subproblem 1 20 n ≤ 100 n≤100 2 22 n ≤ 3
000 n≤3 000 3 58 without additional restrictions Example Sample entry 1 4 1 2 2 3 3 4 1 3 1 4 2 4 Plain text Sample output 1 3 Plain text Sample entry 2 7 1 2 1 3 2 4 2 5 3 6 3 7 1 4 4 5 1 7 7 6 6 2 2 3 Plain text Sample output 2 12 variable inputs
- Assistant