This page is still under construction.

Parts of this page are still being built. What you see may change.

A Math Problem

Time limit1sMemory limit256 MB

Summary
Count the fan-to-team assignments for n fans and m teams where the fan sets are closed under pairwise intersection and union, modulo 10^9+7.
Level

Hard8 of 10

Topics
Math, Combinatorics
Solved
No attempts yet

Statement

There are nn fans FiF_i (i=1,⋯ ,ni=1,\cdots,n) and mm teams TjT_j (j=1,⋯ ,mj=1,\cdots,m).

(i) Each fan FiF_i is a fan of at least one team but not a fan of all teams.

(ii) For any two teams Ti,TjT_i, T_j (1≤i,j≤m1 ≤ i, j ≤ m), there is exactly one team TkT_k (1≤k≤m1 ≤ k ≤ m) whose set of fans is exactly the set of fans shared by TiT_i and TjT_j. ii, jj, and kk may be equal.

(iii) For any two teams Ti,TjT_i, T_j (1≤i,j≤m1 ≤ i, j ≤ m), there is exactly one team TkT_k (1≤k≤m1 ≤ k ≤ m) whose set of fans is exactly the set of fans of TiT_i or TjT_j. ii, jj, and kk may be equal.

Count the number of ways to assign fans to teams (the correspondences between fans and teams) that satisfy these conditions.

Input

The first line contains an integer TT (T≤100000T ≤ 100000), the number of test cases.

Each test case is a single line with two integers nn and mm (1≤n≤10181 ≤ n ≤ 10^{18}, 2≤m≤62 ≤ m ≤ 6).

Output

For each test case, print the answer modulo 109+710^9+7 on its own line.

Examples1

  1. Example 1

    Input
    9
    2 2
    2 3
    3 3
    3 4
    4 4
    4 5
    5 5
    5 6
    6 6
    
    Expected output
    2
    12
    36
    216
    1032
    7200
    46800
    453600
    3369600