402868: GYM100923 L Por Costel and the Semipalindromes
Description
Por Costel the pig, our programmer in-training, has recently returned from the Petrozaporksk training camp. There, he learned a lot of things: how to boil a cob, how to scratch his belly using his keyboard, etc... He almost remembers a programming problem too:
A semipalindrome is a word for which there exists a subword such that is a prefix of and (reverse ) is a suffix of . For example, 'ababba' is a semipalindrom because the subword 'ab' is prefix of 'ababba' and 'ba' is suffix of 'ababba'.
Let's consider only semipalindromes that contain letters 'a' and 'b'. You have to find the -th lexicographical semipalindrome of length .
Por Costel doesn't remember if the statement was exactly like this at Petrozaporksk, but he finds this problem interesting enough and needs your help to solve it.
InputOn the first line of the file semipal.in, there is an integer () representing the number of test cases. On the next lines there are 2 numbers, ( and K where is the number of semipalindromes of length .
OutputIn the output file semipal.out, there should be lines, the -th of which should contain the answer for the -th test.
ExampleInput2Output
5 1
5 14
aaaaa
bbabb