SOLVE
LATER
Alex, a sophomore got inspired to do mathematics after watching a movie "The Man who knew Infinity". One day, he was studying mathematics in the library and in one of the books he discovered a way to perform multiplication of numbers in a new fashion by using digits of a number. He found that method interesting and decided to formulate an algorithm for the same method. Alex finds it difficult to implement and he asks for your help.
Given a number N. Let the first digit of the number be X. P_{1} is the number formed using first X digits of the given number in the sequence. Let the digit after X^{th} digit is Y. P_{2} is another number formed using Y digits starting from (X + 1)^{th} position in sequence and so on. If the number of digits to be used to form a number are more than the remaining digits, then simply form the number using digits till the last digit. Product of (P_{1} * P_{2} * P_{3} ... * P_{i}) is known as magic product. Help Alex to find the magic product.
Input Format:
The first line of the input contains an integer T denoting the number of test cases. Each test case contains a number N followed by values of A and B respectively.
Output Format:
For each test case, output the magic product modulo 10^{A} + B.
Constraints:
NOTE: Any digit in the given number N will not be equal to 0.
Case 1: 54321 = (54321) % (10^{1}+3) = 7
Case 2: 35935 = ( (359) * (35) ) % (10^{2}+9) = 30
Case 3: 46542368 = ( (4654) * (23) * (68) ) % (10^{1}+5) = 1