Karl is developing a key storage service. Each user has a positive integer key.
Karl knows that storing keys in plain text is bad practice. So, instead of storing a key, he decided to store a fingerprint of a key. However, using some existing fingerprint algorithm looked too boring to him, so he invented his own one.
Karl's fingerprint is calculated by the following process: divide the given integer by , then divide the result by , then divide the result by , and so on, until we get a result that equals zero (we are speaking about integer division each time). The fingerprint is defined as the multiset of the remainders of these divisions.
For example, this is how Karl's fingerprint algorithm is applied to the key : divided by has remainder and result , then divided by has remainder and result , and divided by has remainder and result . Thus, the key produces the sequence of remainders [, , ] and has the fingerprint multiset {, , }.
Ksenia wants to prove that Karl's fingerprint algorithm is not very good. For example, she found thatboth keys and produce the fingerprint of {, , , , , , , }. Thus, users are at risk of fingerprint collision with some commonly used and easy to guess keys like .
Ksenia wants to make her words more persuasive. She wants to calculate the number of other keys thathave the same fingerprint as the keys in the given list of some commonly used keys. Your task is tohelp her.
The first line contains an integer (1 \le t \le 50000) - the number of commonly used keys to examine. Each of the next lines contains one integer k_i (1 \le k_i \le 10^{18}) - the key itself.
For each of the keys print one integer - the number of other keys that have the same fingerprint.
Example 1
The other key with the same fingerprint as is . produces a sequence of remainders [, , ]. So both numbers have the fingerprint multiset {, , }.