[Ques] Palindrome Pain solution codechef

[Ques] Palindrome Pain solution codechef

 

You are given two integers XX and YY. You need to construct two different strings S1S1 and S2S2 consisting of only the characters a‘a′ and b‘b′, such that the following conditions are satisfied:

  1. Both S1S1 and S2S2 are palindromes.
  2. Both S1S1 and S2S2 should contain exactly XX occurrences of aa and YY occurrences of bb.

If there are multiple possible answers, you may print any of them. If it is not possible to construct two distinct strings satisfying the conditions, print 1−1 instead.

Input Format

  • The first line of input will contain a single integer TT, denoting the number of test cases. Then the test cases follow.
  • Each test case consists of a single line of input containing two space-separated integers X,YX,Y.

Output Format

For each test case:

  • If it is not possible to construct two distinct strings satisfying the conditions, print 1−1
  • Otherwise, print two lines — the first should contain the string S1S1 and the second should contain S2S2
  • If there are multiple possible answers, you may print any of them.

Constraints

  • 1T10001≤T≤1000
  • 1X,Y1031≤X,Y≤103

Sample Input 1 

2
2 4
3 3

Sample Output 1 

abbbba
babbab
-1

Explanation

Test case 11: The three palindromes containing 22 aa-s and 44 bb-s are abbbba,babbab,abbbba,babbab, and bbaabbbbaabb. Printing any two of these is a valid answer.

Test case 22: There are no palindromes containing 33 each of aa and bb.

Solution

Click Here

Leave a Comment