Loading...
The Odd Truth Behind Her Spell
Time: 1 s
Memory: 125 MB
In the forgotten shadows of Wrylmwood Forest, the ancient witch Areimiena is brewing a potion that will grant her eternal power and dominion over all magical realms. But the potion will succeed only if the secret spell (string \(\boldsymbol{s}\)) can be transformed into a perfect palindrome
If the potion succeeds, Areimiena will rise with fire in her breath and thunder in her gaze. But if it fails, she will be cursed to become a raven, bound to roam the twilight skies forevermore. 
Areimiena now turns to you. Assist her in achieving symmetry in the spell and win her favor... or face her wrath.

You are given a string \(\boldsymbol{s}\) — the secret spell.
You can perform the following operation any number of times (including zero):
  • Choose any contiguous substring of even length from the string and reverse it.
Determine whether it is possible to transform \(\boldsymbol{s}\) into a palindrome.

Note : A palindrome is a string that reads the same forwards and backwards.
Input
The first line contains a single integer \(\boldsymbol{t}\) — the number of test cases.
Each test case consists of two lines:
The first line contains an integer \(\boldsymbol{n}\) — the length of the string.
The second line contains a string \(\boldsymbol{s}\) of length \(\boldsymbol{n}\), consisting only of lowercase English letters.
Constraint
\(\boldsymbol{1 \leq t \leq 500}\)
\(\boldsymbol{1 \leq n \leq 10^3}\)
Output
For each test case, print "the stars align, my power ignites!" if it is possible to transform the string into a palindrome using the allowed operations. Otherwise, print "the curse awakens, wings of the raven rise :(".
Examples
Input
Output
4
5
aabcc
7
racecar
6
abbcad
4
arna
the stars align, my power ignites!
the stars align, my power ignites!
the curse awakens, wings of the raven rise :(
the curse awakens, wings of the raven rise :(
Notes
In the first test case (aabcc), one possible sequence of operations to make the string a palindrome is:
  • Reverse the substring “abcc” (positions 2 to 5, length 4), transforming aabcc→accba.
  • Reverse the substring “cb” (positions 3 to 4, length 2), transforming accba→acbca
Now the string “acbca” is a palindrome.

In the second test case (racecar), the string is already a palindrome, so no operation is needed.
Problem Info
Problem ID 488
Time Limit 1000 ms
Memory Limit 128000 KB
Moderators Falguni_Arna , mahdi_talukder , muhimin , Royboy01
Statistics
Submit
You need to Login or Registration for submit your solution