You have a pile of stones that you want to split into multiple piles, as well as a set, , of distinct integers. We define a move as follows:
You are given queries where each query consists of and . For each query, calculate the maximum possible number of moves you can perform and print it on a new line.
The first line contains an integer, , denoting the number of queries. The subsequent lines describe each query in the following format:
For each query, calculate the maximum possible number of moves you can perform and print it on a new line.
Sample Input 0
2 3 4
Sample Output 0
Initially there is a pile with stones:
You can make a maximal moves, described below:
Select from and split a pile of size into equal piles of size to get:
Repeat the previous move again on another pile of size to get:
As there are no more available moves, we print (the number of moves) on a new line.