#d2612. 进制转换

进制转换

Base Conversion

Problem Description

Let's see who doesn't know base conversion — oh, it turns out to be me.


Given nn non-negative integers in different bases, compute their sum and output it in base mm.

Use uppercase letters A ~ Z to represent 1010 ~ 3535, and lowercase letters a ~ z to represent 3636 ~ 6161.

Input Format

The first line contains two integers 1≤n≤101 \leq n \leq 10 and 2≤m≤622 \leq m \leq 62.

The next nn lines each contain an integer 2≤t≤622 \leq t \leq 62 followed by a tt-base number 0≤x≤1090 \leq x \leq 10^9.

Output Format

One mm-base number, the final result.

Sample Input 1

2 2
2 1
6 10

Sample Output 1

111

Sample Input 2

1 10
52 aA0

Sample Output 2

97864

Sample Input 3

2 52
36 AMD
52 YES

Sample Output 3

dJD