#P4901. Reorder Formation Beauty

    ID: 18142 Type: Default 1000ms 256MiB

Reorder Formation Beauty

Reorder Formation Beauty

Problem Description:

In class CYJianCYJian, the instructor was not impressed with the current formation of the students, so he decided to rearrange the order.

The process is as follows:
1. All students are arranged in a line in increasing order of their student numbers (from 11 to NN).
2. Then, repeatedly, from the current line, he picks students at positions corresponding to the Fibonacci sequence: 1,2,3,5,8,13,1,2,3,5,8,13,\dots (1-indexed). That is, in each iteration, he extracts the students standing in the 1st1^{st}, 2nd2^{nd}, 3rd3^{rd}, 5th5^{th}, 8th8^{th}, 13th13^{th}, ... positions of the current line until no valid position can be chosen. These extracted students form one row (preserving their order) and are appended as the next row in the final formation.

For example, if there are 10 students, the process is illustrated below (bold indicates the picked students):

Initial line: 1 2 3 4 5 6 7 8 9 10
After removal, remaining: 4 6 7 9 10

Iteration 2: current line: 4 6 7 9 10
After removal, remaining: 9

Iteration 3: current line: 9

The final formation is:
- Row 1: 1 2 3 5 8
- Row 2: 4 6 7 10
- Row 3: 9

The beauty of a row is defined as the total number of prime factors (with multiplicity) in the prime factorization of the product of all student numbers in that row. (Note: For the number 11, the count is 00 because 11 does not have any prime factors.)

You are given TT test cases. For each test case, you are provided with two positive integers NN (the number of students) and KK. Your task is to determine the beauty of the KK-th row in the final formation. If the final formation contains fewer than KK rows, output 1-1.

inputFormat

Input Format:
The first line contains an integer TT, the number of test cases.
Each of the next TT lines contains two space‐separated integers NN and KK, where NN is the number of students and KK is the row number (1-indexed) to query.

outputFormat

Output Format:
For each test case, output the beauty of the KK-th row. If the formation has fewer than KK rows, output 1-1.

sample

3
10 2
10 3
10 4
7

2 -1

</p>