You are given some digits. Your task is to find the K-th smallest integer that consists of exactly the digits given, modulo 109+7. You should answer Q such queries (a query consists of digit frequencies and an integer K).
Note that integers with leading zeroes are also taken into account.
The first line contains a single integer Q (1≤Q≤5000).
Each of the next Q lines contains 11 integers. The first ten denote the frequencies of digits 0, 1, …, 9. The last one is the integer K (1≤K≤1012). For each query, the total number of digits is strictly positive and does not exceed 70,000.
Print Q lines. The i-th line must contain one integer: the answer for the i-th query modulo 109+7.