Alpaca Sentence

Find the K-th string in lexicographic order among the shortest palindromes that contain S as a subsequence, or report NONE.

Medium7Dynamic programmingStringCombinatoricsNo attempts yetTime limit3sMemory limit256 MB

Problem

A sentence written by an alpaca has the same letters read forwards and backwards. 'Do geese see god?' (dogeeseseegod), 'Amore, Roma.' and 'Rise to vote, sir.' are alpaca sentences.

Eungi was lying around the alpaca habitat reading alpaca novels. One day the alpacas were digging, and when he looked into the pit he found a stone slab with an ancient sentence written by an alpaca ancestor. Time erased a few letters, but the letters that survived kept their original order. Eungi wants to restore the sentence by inserting lowercase letters into the gaps.

The restored sentence must read the same forwards and backwards, and it must contain the surviving string SS as a subsequence.

Alpacas like short sentences, so the restored sentence has to be as short as possible. Radiometric dating also shows that an alpaca of rank KK wrote it, so among the sentences of minimum length you must choose the KK-th one in lexicographic order.

Help Eungi and write a program that restores the ancient alpaca sentence.

Input

The input consists of two lines.

The first line contains the surviving string SS. SS consists of lowercase letters only, and its length is between 11 and 20002000.

The second line contains the alpaca rank KK, an integer with 1K10181 \le K \le 10^{18}.

Output

Print the restored alpaca sentence on the first line.

If the number of sentences of minimum length is smaller than KK, print NONE.