Problem #364
Nice Fractions
There is a monster who is destroying planet Earth. To counter them, there is a special force of heroes. The heroes are numbered according to their strengths. The strength of the k-th hero is the k-th largest number in the set
S = \{ x \ | \ x = \sum_{i = 1}^{20} \frac{a_i}{6^i}, \ 0 \leq a_i \leq 5 \ \text{for each} \ 1 \leq i \leq 20\}.
Find the strength of the hero who is weaker than 553453543 heroes.
Let M = 10^9 + 7. It can be shown that the answer can be expressed as an irreducible fraction \frac{p}{q}, where p and q are integers and q \not\equiv 0 \pmod{M}.
Output the integer equal to p \cdot q^{-1} \mod M. In other words, output such an integer x that 0 \leq x < M and x \cdot q \equiv p \pmod{M}.