#C8610. Avoiding K-Length Palindromic Substrings

    ID: 52612 Type: Default 1000ms 256MiB

Avoiding K-Length Palindromic Substrings

Avoiding K-Length Palindromic Substrings

You are given two integers N and K. Your task is to construct a string of length N consisting only of characters 'a' and 'b' such that the string does not contain any palindromic substring of length K. A palindromic substring is a sequence of characters that reads the same backward as forward.

If it is not possible to construct such a string, output -1.

Note: For the purpose of this problem, the constructed string is considered valid if it avoids palindromic substrings of length K according to the rules specified.

For example:

  • For N = 5 and K = 2, one possible answer is ababa.
  • For N = 4 and K = 3, it is impossible to construct the string, so the answer is -1.

inputFormat

The first line contains an integer T (the number of test cases).

Each of the next T lines contains two integers N and K separated by a space.

outputFormat

For each test case, output a single line which is either the constructed string of length N without any palindromic substring of length K or -1 if no valid string exists.

## sample
6
5 2
4 3
6 2
1 1
2 2
3 2
ababa

-1 ababab a ab aba

</p>