- محدودیت زمان: ۱ ثانیه
- محدودیت حافظه: ۲۵۶ مگابایت
We have a city with apartments labeled with postal codes to . The th road in this city, connects apartments and . Consider delivering food orders to each apartment in the city in the following manner:
For each , Snapp Food wants to solve the following problem:
- First, deliver order to apartment .
- Then, for each of the food orders in this sequence, deliver the order to the apartment chosen as follows: Choose an apartment that still does not have an order delivered to it and is adjacent to an apartment with an order already delivered to it. If there are multiple such apartments, choose one of them at random.
Find the number of ways in which we can deliver orders to the apartments, modulo
input
The first line of the input is the number of apartments . The following lines, each define a road from apartment to .
output
For each in this sequence, print a line containing the answer to the problem.
example
sample input 1
sample output 1
sample input 2
sample output 2
ارسال پاسخ برای این سؤال