A ticket number that contains exactly 2*K digits is called charming if and only if at least one of the following conditions is satisfied:
- The sum of the first K digits is equal to the sum of the last K digits.
- The sum of all the digits at positions with odd indices is equal to the sum of all the digits at positions with even indices.
Also, you think that some digits are better than others, so a charming number must contain only digits that you consider to be good. These digits are given in the String good. Determine the number of different charming numbers containing exactly 2*K digits. Return this number modulo 999983. Remember that ticket numbers may contain leading zeroes.
|