Under construction

Still being built. Things may change

Password Attacker (Small)

Time limit5sMemory limit512 MB

Summary
Count length-N strings over M given symbols that use every symbol at least once, modulo 1e9+7.
Level

Medium4 of 10

Topics
Combinatorics, Math
Solved
No attempts yet

Problem

Passwords are everywhere in daily life: cash machines, forum logins, phone unlocking, door entry. Everyone cares whether a password is safe, and attackers keep finding ways to steal one. Here is one such situation.

Eve, the attacker, wants Alice's password. Eve wipes the keyboard clean in advance. After Alice types the password and leaves, Eve collects the fingerprints left on the keyboard. Eve now knows which keys the password uses. She does not learn how many times each key was pressed, and she does not learn the order of the keystrokes.

To keep the problem simple, assume the fingerprints Eve finds sit on exactly MM keys. Assume also that Eve knows from another source that Alice's password is NN characters long. Each keystroke produces exactly one character, and Alice presses no other keys such as left, home, or backspace.

A possible password is therefore a string of length NN built only from the MM marked keys, in which each of the MM keys appears at least once.

For example, suppose Eve finds fingerprints on the three keys '3', '7', and '5' (M=3M=3) and the password has four characters (N=4N=4). Then 3577, 3557, 7353, and 5735 are all possible, and there are 36 possible passwords in total. On the other hand 1357 is impossible because key '1' carries no fingerprint. 3355 is impossible because '7' carries a fingerprint and never appears. 357 is impossible because its length is not 4.

Count the possible passwords and report the count modulo 109+710^9+7.

Input

The first line contains the number of test cases TT.

Each of the next TT lines contains two integers MM and NN separated by a space, describing one test case.

Output

For each test case, print one line in the form Case #x: y, where xx is the test case number starting at 1 and yy is the number of possible passwords modulo 109+710^9+7.

Constraints

  • 1≤T≤151 \le T \le 15
  • 1≤M≤N≤151 \le M \le N \le 15

Examples2

  1. Example 1

    Input
    4
    1 1
    3 4
    5 5
    15 15
    
    Expected output
    Case #1: 1
    Case #2: 36
    Case #3: 120
    Case #4: 674358851
    
  2. Example 2

    Input
    3
    1 7
    2 7
    7 7
    
    Expected output
    Case #1: 1
    Case #2: 126
    Case #3: 5040