#P1591. 阶乘数码

阶乘数码

Description

Find how many times a certain digit appears in n!n!.

Input Format

The first line contains tt (t10t \leq 10), indicating the number of test cases.
Each of the next tt lines contains a positive integer nn (n1000n \leq 1000) and a digit aa.

Output Format

For each test case, output a single integer, the number of times aa appears in n!n!.

2
5 2
7 0
1
2

Hint

Translated by ChatGPT 5