CF1476A.divisible Sum

传统题 时间 2000 ms 内存 256 MiB 5 尝试 1 已通过 1 标签

divisible Sum

You are given two integers nn and kk.

You should create an array of nn positive integers a1,a2,,ana_1, a_2, \dots, a_n such that the sum (a1+a2++an)(a_1 + a_2 + \dots + a_n) is divisible by kk and maximum element in aa is minimum possible.

What is the minimum possible maximum element in aa?

Input

The first line contains a single integer tt (1t10001 \le t \le 1000) — the number of test cases.

The first and only line of each test case contains two integers nn and kk (1n1091 \le n \le 10^9; 1k1091 \le k \le 10^9).

Output

For each test case, print one integer — the minimum possible maximum element in array aa such that the sum (a1++an)(a_1 + \dots + a_n) is divisible by kk.

Note

In the first test case n=1n = 1, so the array consists of one element a1a_1 and if we make a1=5a_1 = 5 it will be divisible by k=5k = 5 and the minimum possible.

In the second test case, we can create array a=[1,2,1,2]a = [1, 2, 1, 2]. The sum is divisible by k=3k = 3 and the maximum is equal to 22.

In the third test case, we can create array a=[1,1,1,1,1,1,1,1]a = [1, 1, 1, 1, 1, 1, 1, 1]. The sum is divisible by k=8k = 8 and the maximum is equal to 11.

Samples

4
1 5
4 3
8 8
8 17
5
2
1
3

在线编程 IDE

建议全屏模式获得最佳体验