The first line of input contains a single integer P, (1 <= P <= 1000) , which is the number o data sets that follow. 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 10,000,000.