SP119 SERVERS - Servers

Description

The Kingdom of Byteland decided to develop a large computer network of servers offering various services. The network is built of n servers connected by bidirectional wires. Two servers can be directly connected by at most one wire. Each server can be directly connected to at most 10 other servers and every two servers are connected with some path in the network. Each wire has a fixed positive data transmission time measured in milliseconds. The distance (in milliseconds) D(V, W) between two servers V and W is defined as the length of the shortest (transmission time-wise) path connecting V and W in the network. For convenience we let D(V, V) = 0 for all V. Some servers offer more services than others. Therefore each server V is marked with a natural number r(V), called a rank. The bigger the rank the more powerful a server is. At each server, data about nearby servers should be stored. However, not all servers are interesting. The data about distant servers with low ranks do not have to be stored. More specifically, a server W is interesting for a server V if for every server U such that D(V, U)

Input Format

The input begins with the integer z, the number of test cases. Then z test cases follow. For each test case, in the first line there are two natural numbers n, m, where n is the number of servers in the network (1

Output Format

For each test case the output consists of a single integer equal to the total amount of data about servers that need to be stored in the network.