26775: Eleven

题目描述

Fat Brother loves playing games with number, such like “Calculating 24”, “Sudoku” and so on. Now consider about a special game called “Eleven”. In this game, Fat Brother has to write down an integer without leading zero by using each of the digits certain times and his goal is to make this number can be divided by 11. For example, given one digit 1 and two digits 6, Fat Brother can write integer 616 since this integer can be divided by 11. Also this is the only integer you can write by using these digits.

Now Fat Brother gets some digits in a game. Your task is to help him determined how many different integer he can write to fulfill the requirement.

输入

The first line of the date is an integer T (T <= 100), which is the number of the text cases.

Then T cases follow, each case contains ten integers which indicate the number of each digit, from 0 to 9. The sum of the number of each line is no large than 100.

输出

For each case, outputs the case number first, and then output the number of different integers that Fat Brother can write to fulfill the requirement. Since this number maybe quite large, you should just output the answer module 10007.