BETA

Difficulty Level:

Easy

Total Submissions: 148 Accuracy:

22.3%

Number of subsequences in a string divisible by n
     

Given a string consisting of digits 0-9, count the number of subsequences in it divisible by n.

 

Input:

The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. The first line of each test case contains an integer M and N where M denotes the length of the numeric string.

The second line of each test case contains the numeric string.


Output:

Output the number of subsequences dicisible by N. Since the number can be quite large print the answer modulo 109+7.


Constraints:

1<= T <=100

1<= M <=1000

1<= N <=1000


Example:

Input:

2

4 4

1234

3 6

330

Output:

4

4

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Sujnesh Mishra

Set Default Code

					   
It is recommended to 'Compile & Test' your code before clicking 'Submit'!

Compilation/Execution Result:

Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.