Divide Candies

0

0 votes
Very-Easy
Problem

The problem is very simple. There are k children and n candies. The candies are to be divided among the children such that each child receives equal number of candies.

Find the number of remaining candies that could not be divided among the children.

Input

The first line contains an integer t denoting the total number of test cases.

Each of the next t lines contains 2 integers n and k denoting the number of candies and the children respectively.

Output

For each test case, print an integer denoting the remaining candies.

Constraints

t=105

1n1018

1k1018

Note: Since the n and k can be as large as 1018, storing them in integer variables would result in a wrong answer.

Time Limit: 1
Memory Limit: 256
Source Limit:
Editor Image

?