Now that you believe Jiajia & Wind's cute daughter, Autumn, is a genius. It's not surprising that such a clever little girl would have no interest on simple additions very soon. This time, she turned to divisions, since they're more fun. For example, she found herself that if the sum of digits of a decimal number is a multiple of 3, then the decimal number itself is also a multiple of 3. The argument is still true if she replaces the number 3 with 9.
Inspired by these, Autumn invented a special kind of number, called 'Beautiful Numbers'. A number k is said to be Beautiful in base b, if the sum of digits of k in base b is a multiple of b.
Autumn knows how to calculate the sum of first n beautiful numbers in base b, can you?