#K71722. Coin Distribution Difference

    ID: 33595 Type: Default 1000ms 256MiB

Coin Distribution Difference

Coin Distribution Difference

You are given a number of coins and a number of boxes. Your task is to distribute all the coins into the boxes as evenly as possible. In other words, you need to minimize the difference between the number of coins in the box with the most coins and the box with the fewest coins.

More formally, for each test case you are given two integers \(N\) and \(K\) representing the total number of coins and the number of boxes respectively. When the coins are distributed evenly among the boxes, some boxes may receive one more coin than others if \(N\) is not divisible by \(K\). The goal is to compute the minimum possible difference between the maximum number of coins in any box and the minimum number of coins in any box.

The answer for each test case is \(0\) if \(N\) is divisible by \(K\) and \(1\) otherwise.

inputFormat

The first line contains an integer \(T\) representing the number of test cases.

Each of the next \(T\) lines contains two space-separated integers \(N\) and \(K\), where \(N\) is the total number of coins and \(K\) is the number of boxes.

outputFormat

For each test case, output a single line containing the minimum possible difference between the number of coins in the fullest and the emptiest box.

## sample
3
7 3
10 2
5 5
1

0 0

</p>