Given a string S, consisting only of ‘0’ and ‘1’, and also you are given an integer k. You are asked to find the sum of all unique substrings (in decimal notation) of length k in the string, such that string S is the repetition of these substrings. If the string S can’t be split into substrings of length k without leaving any characters in the string, print -1.

Input:
The first line consists of a single integer T denoting the number of test cases. Next T lines follow each of which consists of string S and an integer k.

Output:
For each test case, print in new line the sum as described in the problem. Print your answer modulo 10^9 + 7.

Constraints:
1 <= T <= 10^3
1 <= Length |String| <= 10^6
1 <= k <= 25, k<=Length |String|

Example:

Input:

2
010100010010 3
00100110 4

Output:
6
8

Explanation:

Case 1: Unique substrings are “010” and “100”. The required sum is 2+4=6.

Case 2: Unique substrings are "0010" and "0110". Hence, the sum = 2 + 6 = 8.