Palindrome Game (hard Version)

medium
https://codeforces.com/problemset/problem/1527/B2

Input Format

Check the link

Output Format

Check the link

Constraints

Check the link

Example

Input

        
Output

        
Previous
Palindrome Game (easy Version)
Next
Grundy Number

Related Questions