You are given an integer N that is represented in the form of string S of length M. You can remove at most 1 digit from the number after removing the rest of the digits that are arranged in the same order.
Example
For N=2134, if you delete the digit 3, the new number is 214.
You are also given an integer K. Find the maximum possible value of (N mod K) after deleting at most 1 digit from number N.
Input format
Output format
For each test case, print the maximum possible value of the mod function in a new line.
Constraints
1≤T≤101≤N≤101051≤K≤109
If we remove the last digit from the number N, then the new number will be 5243.