P15891 [HackerEarth] Lissa has just won the HackerEarth Online Coding Contest. Kuldeep decided to offer her N chocolate boxes each containing at least one chocolate in it. But he knows that Lissa does not li
普及
题目描述

Lissa has just won the HackerEarth Online Coding Contest. Kuldeep decided to offer her N chocolate boxes each containing at least one chocolate in it. But he knows that Lissa does not like chocolates very much so he wants to place chocolates in the boxes such that the total number of chocolates is minimum.

Given a number N denoting the number of boxes and a number K denoting the product of the number of chocolates in the N boxes, you need to tell Kuldeep the minimum of total number of chocolates that can be placed in the boxes.

Input:

First line of input contains an integer T denoting the total number of test cases.

Each test case consists of a single line containing two space separated integers N and K denoting the number of boxes and the product of the chocolates in n boxes.

Output:

Output consists of T lines each containing an integer denoting the minimum of total number of chocolates in the N boxes.

Constraints:

T ≤ 1000

N ≤ 1000

K ≤ 10^9

SAMPLE INPUT
4
2 24
3 24
3 60
4 60

SAMPLE OUTPUT
10
9
12
12

Explanation

test 1: 1st box contains 6 chocolates and 2nd box contains 4 chocolates . So, the total number of chocolates in N boxes are 10 and their product is 24.

test 2: 1st box contains 4 chocolates and 2nd box contains 3 chocolates and 3rd box contains 2 chocolates.So, the total number of chocolates in N boxes are 9 and their product is 24.

输入格式

见题面

输出格式

见题面

样例输入
100 25 2644724 86 6557192 39 5232455 49 5525487 19 8757795 37 3647218 13 2187631 27 4061905 17 5968008 84 9452659 49 7552838 82 7137299 43 8523338 63 9568229 68 6658975 9 3629582 26 592913 87 8441289 6 3937794 43 7106372 98 8560791 8 3940727 65 5060662 6 5241983 23 5233659 49 5923584 48 9387508 67 4498485 96 4603515 79 8251012 92 8116181 18 8459870 9 4142902 40 3801188 33 3227043 64 6202958 75 1711874 89 3600181 79 7717901 1 2344962 87 3524387 40 7105205 52 9120092 44 4257323 93 4330033 15 1478447 99 7030781 12 4306678 81 2923431 70 2065876 15 2954278 61 995750 25 5148168 76 5641306 68 408710 65 5264465 50 9389864 58 8827679 5 1324624 54 7957689 45 6722529 30 6097571 73 1992489 27 3414241 24 6456545 58 5550943 60 86360 85 9421521 56 8678257 30 7215399 32 4727477 24 6185695 34 7959133 31 9840839 61 1592190 52 4578140 54 7734308 65 8245778 41 758045 55 9451739 67 6597410 63 3194695 84 9510925 32 1448335 6 8725983 88 4347244 59 6450564 77 8518036 13 2004387 14 7980576 7 4491698 81 7483022 86 9251662 6 3068515 31 8774421 9 1915745 31 8299166 85 5487083 13 7549069 44 6882822
样例输出
2490 880264 7311 249 461658 19335 238164 929 2066 1920