# Виток 1, Шаг 6 - Строки

# B-Casting

Casting around for problems leads us to combine modular arithmetic with different integer bases, particularly the problem of computing values modulo **b** - **1**, where **b** is the base in which the value is represented. For example,

`7829`

mod _{10}**9** = **8**

`37777777777777773`

mod _{8}**7** = **6**

`123456`

mod _{7}**6** = **3**

(Note that `37777777777777773`

= _{8}`1125899906842619`

and _{10}`123456`

= _{7}`22875`

)_{10}

Your job is to write a program that reads integer values in various bases and computes the remainder after dividing these values by one less than the input base.

#### Input

The first line contains the number of data sets **t** (**1** ≤ **t** ≤ **1000**). Each data set should be processed identically and independently.

Each data set consists of a single line of input containing three space-separated values. The first is an integer which is the data set number. The second is an integer which is the number **b** (**2** ≤ **b** ≤ **10**), denoting a numeric base. The third is an unsigned number **d**, in base **b** representation. For this problem, the number of numeric characters in **d** will be limited to **10000000**.

#### Output

For each data set there is a single line of output. It contains the data set number followed by a single space which is then followed by the remainder resulting from dividing **d** by (**b** - **l**).

5 1 10 7829 2 7 123456 3 6 432504023545112 4 8 37777777777777773 5 2 10110100010101010101101110001010001010101010101010111

1 8 2 3 3 1 4 6 5 0