6548: Random

内存限制:64 MB 时间限制:1.000 S
评测方式:文本比较 命题人:
提交:41 解决:6

题目描述

N numbers, randomly generated between [0,1]
Make M operation, 1/2 probability to delete the maximum value, 1/2 probability to delete the minimum value
Calculate the sum of expected value module 109+7

输入

Each test contains multiple test cases. The first line contains the number of test cases (1≤T≤10000). Description of the test cases follows.

The first line of each test case contains two integers n,m

1≤mn≤109

输出

For each test case, print one integer — the answer to the problem.

样例输入 复制

2
2 2
3 1

样例输出 复制

0
1