One of your friends desperately needs your help. He is working with a secret agency and doing some encoding stuffs. As the mission is confidential he does not tell you much about that, he just want you to help him with a special property of a number. This property can be expressed as a function for a positive integer . It is defined as:

In other words, he needs the sum of all possible pairs whose least common multiple is . The least common multiple (LCM) of two numbers and is the lowest positive integer which can be perfectly divided by both and . For example, there are different pairs having their LCM equal to as , , , , . So is calculated as f(6) = (1 + 6) + (2 + 6) + (2 + 3) + (3 + 6) + (6 + 6) = 7 + 8 + 5 + 9 + 12 = 41.
Your friend knows you are good at solving this kind of problems, so he asked you to lend a hand. He also does not want to disturb you much, so to assist you he has factorized the number. He thinks it may help you.
The first line will contain the number of test cases (t \leq 500). After that there will be test cases. Each of the test cases will start with a positive number (c \leq 5) denoting the number of prime factors of . Then there will be lines each containing two numbers p_i and a_i denoting the prime factor and its power (p_i is a prime between and and 1 \leq a_i \leq 50). All the primes for an input case will be distinct.
For each of the test cases produce one line of output denoting the case number and modulo . See the output for sample input for exact formatting.
Example 1