At least how many in one box?

If N items go into k boxes, the pigeonhole principle guarantees that some box holds at least ⌈N/k⌉ items. Your program computes this guarantee for several cases.

What to build

A program that prints, for each case, the least number of items that some box must hold.

Requirements

  • Read the number of cases t, then t lines with N and k.
  • For each case print the smallest number that some box is certain to hold at least: the ceiling of N divided by k.

Input

The first line has t. Each of the next t lines has N and k.

Output

One number for each case.

Constraints

1 ≤ t ≤ 20; 1 ≤ N ≤ 10 to the power 6; 1 ≤ k ≤ 1000.

Example

Input:

3
100 7
13 12
50 6

Output:

15
2
9

Why it works

If every box held fewer than ⌈N/k⌉ items, the total would be less than k × ⌈N/k⌉ at most k × (⌈N/k⌉ − 1), which is smaller than N. So some box holds at least the ceiling. In integer arithmetic the ceiling is (N + k − 1) // k.

Examples

Example 1 · Input
3
100 7
13 12
50 6
Expected output
15
2
9
Example 2 · Input
2
367 366
10 10
Expected output
2
1

Prompts inside input() are ignored when checking, so input("n: ") is fine.

Hints

Hint 1

Some box holds at least ceil(N / k) items.

Hint 2

With integers, the ceiling of N / k is (N + k - 1) // k.

Hint 3

Print one number per case.

Solution

Show one correct solution (try it yourself first)
t = int(input())
for _ in range(t):
    n, k = map(int, input().split())
    print((n + k - 1) // k)

▶ Open this solution in the compiler, then press Visualize to watch it run step by step

Lesson: The pigeonhole principle and inclusion-exclusion →