P10981 [HackerEarth] question 2 20
普及
题目描述

Problem Statement:
Nash, a high school student studies the concepts of Functions(Mathematics), for the first time.After learning the definitions of Domain and Range, he tries to find the number of functions possible,given the number of elements in domain and range.He comes to you for help.Can you help him with this?

Input Format:
The first line of Input contains t,the number of testcases. Then t lines follow, each line consist of two integers X and Y, indicating the size of domain and range.

Output Format:
For each testcase, output a single number which is the number of functions that can be created for given size of Domain and Range.Since the answer can be large, output the value of ans%1000000007(ie the reminder when the ans is divided by 10e9+7).

Input Constraints:
1 ≤ t ≤ 100
1 ≤ X ≤ 1000
1 ≤ Y ≤ 1000

SAMPLE INPUT
2
2 4
1 1

SAMPLE OUTPUT
16
1

Explanation

For the first input, the number of functions possible is 16.The reminder when 16 is divided by 10e9 + 7 is 16.(Quotient is 0).
Similarly, the output value for second testcase is 1.

输入格式

见题面

输出格式

见题面

样例输入
47 428 580 692 254 221 613 14 794 116 115 926 200 325 265 517 290 219 90 947 543 218 544 149 976 28 233 879 494 530 715 853 618 5 378 369 781 813 967 880 841 610 707 205 655 73 468 187 715 442 535 413 765 152 199 72 58 24 116 900 962 982 272 694 763 372 478 210 830 628 348 895 136 663 187 595 76 271 220 449 414 611 749 959 627 441 188 309 528 713 196 891 144 886 998
样例输出
33172914 969001528 763558838 264421526 408857237 138817814 945568635 679200755 136796419 431775807 403600246 592139643 998347316 775182218 806076022 275325338 186504349 459109290 586196054 465998479 743346655 956463920 966983531 863722125 55560866 375873458 439742780 315389316 117263467 440998506 531892981 911973175 368768052 808296506 182228648 359621874 233396409 249709483 628904483 739769030 558447399 150083872 539262880 576043888 404562125 723117300 294016284