Calculate the Sum

Time Limit:1000MS  Memory Limit:65535KB
Description:
   As you all know, MOD is a mathematical operatio. Giving you two numbers n,m(0 < m,n <= 1010001),Your task is to calculate the sum of every digit of m MOD every digit of n. We can guarantee that there is no zero in digits of n. 
Input:
The first line, a integer T, representing T test cases blew.(T<=10).
In each case, the first line is the integer m, the second line is the integer n. 
Output:
Print the sum of every digit of m MOD every digit of n.
Sample test:
Input
1
13
21
Output
2
Note:
Source:
Author:
ACSolo