1304  Get Kbased number
Time Limit : 1 Second
Memory Limit : 128 MB
Submission: 136
Solved: 39
 Description
 First define a special KBase number system. For each number in this system, the number can not contain more than K dights. And From left to right, the ith digits can use dight 0 to i(A dights more than 9 use A,B,C…… stands for)
For example:
If K=3, the first 15 number is 000,001,002,003,010,011,012,013,020,021,022,023,100,101,102
Now please convert the special Kbased number and decimal number.  Input
 Multi case ending in EOF.
For each case, the first line has two numbers Q and K, indicate Kbased number system(2<=K<=16) and Q questions.(1<=Q<=20)
Next Q lines, each line has two number C and N (if C=2, N will include Uppercases)  Output
 For each question:
If C=1 output the Nth number in the Kbased number system.
If C=2 for a Kbased number, output in the system, the position of the number(the first pos is 1)  sample input

5 3 1 1 1 5 2 013 1 10 1 15 1 4 2 1234
 sample output

000 010 8 021 102 120
 hint
 source
 Hust Monthly 09.08.21/Zehua HONG