P23720 [AtCoder] [ABC025A] 25 Strings
入门
题目描述

Problem Description

Takahashi is thinking of a short nickname. The nickname consists of two lowercase alphabets.

Takahashi has five favorite alphabets. Takahashi considers all strings of length 2 that satisfy the following condition and calls the set of these strings the "set of nickname candidates".

  • Condition: Both the first and the second characters of the string are one of Takahashi's five favorite alphabets.

Here, for two different length-2 strings \( S \) and \( T \), \( S \) comes before \( T \) in lexicographical order if any of the following conditions is met:

  • The first character of string \( S \) is different from the first character of string \( T \), and the first character of string \( S \) comes before the first character of string \( T \) in alphabetical order.
  • The first characters of strings \( S \) and \( T \) are the same, and the second character of string \( S \) comes before the second character of string \( T \) in alphabetical order.

For example, if the favorite alphabets are a, b, c, d, e, the strings in the "set of nickname candidates" in lexicographical order are: aa, ab, ac, ad, ae, ba, bb, bc, bd, be, ca, cb, cc, cd, ce, da, db, dc, dd, de, ea, eb, ec, ed, ee.

There are a total of 25 strings in the "set of nickname candidates". Takahashi decided to use the \( N \)-th string in lexicographical order from the beginning as his final nickname.

Your task is to determine the final nickname defined by Takahashi.

Input Format

The input is given from the standard input in the following format:

\( S \) \( N \)

  • The first line contains a string \( S \) of length 5. Each character in \( S \) is a lowercase alphabet, and there are no duplicates in \( S \), which is sorted in ascending order. That is, the \( i \)-th character (1 ≦ \( i \) ≦ 5) from the left of string \( S \) is \( c_i \), and \( c_i ≠ c_j \) (i ≠ j), and if \( i < j \), alphabet \( c_i \) comes before alphabet \( c_j \) in alphabetical order.
  • The second line contains an integer \( N \) (1 ≦ \( N \) ≦ 25).

Output Format

Output the final nickname defined by Takahashi in one line. End the output with a newline.

Sample Input and Output

Sample Input #1

abcde
8

Sample Output #1

bc

Sample Input #2

aeiou
22

Sample Output #2

ue

Sample Input #3

vwxyz
25

Sample Output #3

zz

Notes/Hints

Sample Explanation 1

  • The "set of nickname candidates" is the same as the example in the problem statement. The 8th string in lexicographical order in the "set of nickname candidates" is bc, so bc is output.
输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
abcde 8
样例输出
bc