Cyclic Rotation Cipher

No attempts yetTime limit1sMemory limit32 MB

Problem

For some time the police have been intercepting encrypted messages from a criminal group, but they have been unable to decrypt them. During a recent raid of an abandoned warehouse they seized the encryption device, and careful analysis revealed how it works.

The device takes plain text as input. The text is first converted to lowercase and stripped of everything except the Latin letters az, producing a string S=s1s2snS = s_1 s_2 \dots s_n. Then all nn cyclic rotations of SS (call them S1SnS_1 \dots S_n, where Si=sisns1si1S_i = s_i \dots s_n s_1 \dots s_{i-1}) are sorted lexicographically. The encrypted message consists of the index ii of the original string among the sorted rotations, together with a string RR formed by taking the last letter of every rotation, read in sorted order.

For example, abracadabra is encoded as 3 rdarcaaaabb:

 1. aabracadabr = S11
 2. abraabracad = S8
 3. abracadabra = S1
 4. acadabraabr = S4
 5. adabraabrac = S6
 6. braabracada = S9
 7. bracadabraa = S2
 8. cadabraabra = S5
 9. dabraabraca = S7
10. raabracadab = S10
11. racadabraab = S3

The sorted rotations are numbered 11 to 1111; the third one is the original string, so i=3i = 3, and reading the last letter of each rotation from top to bottom gives rdarcaaaabb.

Given an encrypted message (i,R)(i, R), recover the original string SS. The messages can be very long, so your program must be efficient.

Input

The first line contains the index ii (1in1 \le i \le n). The second line contains the string RR of length nn (1n10000001 \le n \le 1\,000\,000). The original message SS is guaranteed to exist and to be unique.

Output

Print the string SS on a single line.