Time limit
2s
Memory limit
128 MB
In the new phone number system, every number is a 7-character hexadecimal string. The distance between two phone numbers is the number of positions where their characters differ. For example, 1b100fa and 11b0ffa have distance 3 because positions 2, 3, and 5 are different.
Numbers are assigned one at a time so that the distance between any two assigned numbers is at least S. Whenever a new number is needed, choose the smallest 7-character hexadecimal string, equivalently the smallest numeric value, that keeps this condition true.
Given S and K, output the K-th phone number assigned by this rule.
The first line contains S and K separated by a space. S is an integer from 1 to 3, and K is a positive integer not greater than 300,000.
Print the K-th phone number on the first line. Any hexadecimal letters must be printed in lowercase.