Cutting the Ribbon Banner (easy version)
A ribbon banner carries a string s of n lowercase English letters. The banner must be cut
exactly once, between two neighbouring letters, into two non-empty pieces, and each piece must read
the same from left to right as from right to left (it must be a palindrome).
A cut at position i (1 ≤ i ≤ n − 1) splits the banner into the first piece s[1..i] (the
first i letters) and the second piece s[i+1..n] (the remaining n − i letters).
Find the smallest position i where the banner can be cut so that both pieces are palindromes.
Input
The first line contains an integer n (1 ≤ n ≤ 1000), the length of the banner.
The second line contains the string s of exactly n lowercase English letters.
Output
Print the smallest cut position i (1 ≤ i ≤ n − 1) such that both s[1..i] and s[i+1..n] are
palindromes, or -1 if no such position exists.
Notes
In the first example, noonabba is cut after the fourth letter into noon and abba. No earlier
cut works: for example, n is a palindrome but oonabba is not.
In the second example, neither a | bc nor ab | c gives two palindromes, so the answer is -1.
In the third example, every cut of aaaa works, and the smallest position is 1. A single letter
is a palindrome, but a piece may never be empty, so a banner with just one letter can't be cut at
all.