时间限制:C/C++/Rust/Pascal 2秒,其他语言4秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld
题目描述
Country A has

cities, labeled from

to

.
At the beginning, the government needs to build roads between these cities. The king of Country A loves binary numbers, so he assigns a number to each city --- the number for the

-th city is

.
For any two cities

and

(where

<

), the king builds
directed roads from city

to city

. (The meaning of the symbols is explained at the end of the problem.)
Now, the king wants to know: How many ways are there going from city

to city

? The answer should be printed modulo

.
The function
)
counts how many

's are in the binary (base-

) form of

. For example,
%20%3D%202)
(since

in binary is

, which has two

's).

denotes the bitwise AND, for example:
which denotes

.
输入描述:
The first line contains an integer
(
), denoting the number of test cases.
For each test case, the first line contains an integer
(
), denoting the number of cities.
The second line contains
integers
(
).
输出描述:
For each test case, output the number of different paths from city
to city
, modulo
.
示例1
输入
复制
3
3
7 4 5
5
3 3 3 3 3
5
290109 290105 278130 123019 100290
备注:
There are three paths of the first test case:
,
,
. Note that travel through different roads of the same two cities denotes different paths.