In order to develop local tourism, Major Fu plans to introduce several bus routes between attractions in his city. There are $M$ types of buses, namely the Green Bus, the Red Bus, the Blue Bus, etc., and $N$ attractions in his city. He wants the arrangement to satisfy the following requirements:

$\cdot$There is at most one type of buses between any two attractions.

$\cdot$Visitors can travel between any two attractions by bus.

$\cdot$Many visitors likes circle trip, in which the visitors start from an attraction and get back to the attraction via a sequence of other attractions. At least one circle trip should be made available via buses. The circle trips do not have to contain all attractions.

Can you help him to calculate the number of ways he can arrange the bus routes? Please note that you do not need to use all types of buses in each arrangement and bus routes are two-way.

$\cdot$There is at most one type of buses between any two attractions.

$\cdot$Visitors can travel between any two attractions by bus.

$\cdot$Many visitors likes circle trip, in which the visitors start from an attraction and get back to the attraction via a sequence of other attractions. At least one circle trip should be made available via buses. The circle trips do not have to contain all attractions.

Can you help him to calculate the number of ways he can arrange the bus routes? Please note that you do not need to use all types of buses in each arrangement and bus routes are two-way.

The first line of input contains a number $T$ indicating the number of test cases ($T≤200$).

For each case, there is only one single line containing two non-negative integer $N$ and $M$ ($1<N≤10000,0<M<2^{31}$).

For each case, there is only one single line containing two non-negative integer $N$ and $M$ ($1<N≤10000,0<M<2^{31}$).

提交代码