Little Gyro has just found an empty integer set A in his right pocket, and an empty integer set B in his left pocket. At the same time, Little Gyro has already thought about two integers n, m in his mind. As Little Gyro is bored, he decides to play with these two sets. Then, Little Gyro is ready to divide the integer series 1,2,3...m−1,m to these two empty sets. With the following rules: If the number is an integer multiple of n, Little Gyro will put it in set A. Otherwise, Little Gyro will put it in set B instead. Now given two integers n, m, after these operations, Little Gyro wants to know the result of sum(B)−sum(A) and ask you for help, please help him to calculate. Input Specification: There are multiple test cases. The first line of the input contains an integer T (1 ≤ T ≤ 10 5 ), indicating the number of test cases. For each test case: Each line contains two integers n, m (1 ≤ n, m ≤ 10 9 ), indicating the length of the sequence. Output Specification: For each test case output an integer indicating the result of sum(B)−sum(A). Sample Input: 3 3 5 2 10 3 16 Sample Output: 9 -5 46 Hint: For the first sample, after these operations, A = <3>, B = <1,2,4,5>, and the answer is 9. For the second sample, after these operations, A = <2,4,6,8,10>, B = <1,3,5,7,9>, and the answer is -5.
最新发布