Under construction

Still being built. Things may change

Light Bulb Sequence

Time limit2sMemory limit1024 MB

Summary
Counts the bulbs still on after k rounds, where round i flips every bulb whose number is divisible by i, with n at most 10k.
Level

Hard8 of 10

Topics
Number theory, Math
Solved
No attempts yet

Problem

The stage for the next Hunger Games opening ceremony is being prepared. One of the decorations is a row of light bulbs hanging above the stage. The row has nn bulbs, numbered from 11 to nn.

All bulbs start off. During the ceremony, the bulbs will be operated on kk times. During the ii-th operation (1≤i≤k1 \le i \le k), the state of every bulb whose number is divisible by ii is flipped: an off bulb turns on, and an on bulb turns off. For a reason known only to the chief designer, nn does not exceed 10k10k.

The chief designer wants to know how many bulbs are still on after all operations. Help him.

The number of bulbs and the number of operations are not yet final. There are tt possible cases, and the designer gave a list of tt pairs nin_i and kik_i. For each case, print the number of bulbs that are on at the end.

Input

The first line contains an integer tt (1≤t≤1001 \le t \le 100), the number of possible cases. Each of the next tt lines contains nin_i and kik_i (1≤ni≤10181 \le n_i \le 10^{18}, 1≤ki≤10181 \le k_i \le 10^{18}, ni≤10kin_i \le 10k_i).

Output

Print tt lines, each containing the answer for one case.

Examples1

  1. Example 1

    Input
    2
    8 5
    5 1
    
    Expected output
    5
    5