Saturday, April 16, 2022

Palindrome Pain

 You are given two integers 

X and Y. You need to construct two different strings S1 and S2 consisting of only the characters a and b, such that the following conditions are satisfied:

  1. Both S1 and S2 are palindromes.
  2. Both S1 and S2 should contain exactly X occurrences of a and Y occurrences of b.

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 instead.

Input Format

  • The first line of input will contain a single integer T, 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,Y.

Output Format

For each test case:

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

Constraints

  • 1T1000
  • 1X,Y103

Sample Input 1 

2
2 4
3 3

Sample Output 1 

abbbba
babbab
-1

Explanation

Test case 1: The three palindromes containing 2 a-s and 4 b-s are abbbba,babbab, and bbaabb. Printing any two of these is a valid answer.

Test case 2: There are no palindromes containing 3 each of a and b.

No comments:

Post a Comment

मुझे दिल में बसाना आसान नहीं....

पता है Recently i realised की मुझे दिल में बसाना आसान नहीं है बात-बात पे चिढ़ जाती हूं मैं दिल लगा लूं एक बार तो फिर ज़िद पे अड़...