Surface:

One day, Sailormoon Girls is so delighted the they intend to the, about palindromic strings. Operation contains, steps:

First Step:girls would write a long string (only contains lower case) on the paper. For example, "ABCDE", but ' a ' inside was not the real ' a ', so means if we define the ' B ' is the real ' a ' and then we can inf Er that ' C ' are the real ' B ', ' d ' is the real ' C ' ..., ' a ' is the real ' z '. According to this, the string "ABCDE" Changes to "Bcdef".

Second Step:girls'll find out the longest palindromic string in the given string, the length of palindromic string must be equal or more than 2.

**Input**

Input contains multiple cases.

Each case contains parts, a character and a string, they is separated by one space, the character representing the RE Al ' A ' is and the length of the string won't exceed 200000.All input must be lowercase.

If the length of string is Len, it's marked from 0 to len-1.

**Output**

Please execute the operation following the steps.

If you find one, output the start position and end position of palindromic string in a line, next line output the real pal Indromic string, or output "No solution!".

If There is several answers available, please choose the string which first appears.

**Sample Input**

b babd

a ABCD

**Sample Output**

0 2

Aza

No solution!

Main topic:

Now there is a string with some palindrome strings inside. Now let you find out which one is the longest and output.

But there is another condition, each string preceded by a character that represents a set of substitution rules.

If it's B, then it's \ (b->a,c->b,d->c...a->z\)

Finally, the replacement string is output and the left and right bounds of the string are output (character numbering starts at 0).

General idea:

If there is no replacement rule, it is a manaler bare template. Then, the longest palindrome string to be obtained and the relative position of some operations.

This operation is divided into when \ (pos\) is an odd or even number.

Vo specific operation look at the code

`//pos是定位的最长回文串的位置，len是对应的长度if(pos%2){ l=pos-(len-1); l/=2; --l; r=pos+(len-1); r/=2; --r;}else{ mid=pos/2; l=mid-len/2-1; r=mid+len/2-1;}`

Code:

`#include <bits/stdc++.h>using namespace Std;const int Maxn=2e5+7;char str[maxn],tran[maxn<<2],basc;int p[ maxn<<2];void print (int len) {for (int i=1;i<len;++i) cout<<p[i]<< ""; Cout<<endl;} void Manaler () {memset (tran,0,sizeof (Tran)); memset (P,0,sizeof (p)); int Len_1=strlen (str), len_2=1; Tran[0]= ' $ '; for (int i=0;i<len_1;++i) {tran[len_2++]= ' # '; Tran[len_2++]=str[i]; } tran[len_2++]= ' # '; tran[len_2]= ' + '; int mi=0,r=0; for (int i=1;i<len_2;++i) {if (i<=r) p[i] = min (r-i,p[2*mi-i]); else p[i]=1; while (Tran[i-p[i]]==tran[i+p[i]]) ++p[i]; if (i+p[i]>r) {r = I+p[i]; Mi=i; }}//print (len_2); int k=basc-' a ', pos=0,len=0; for (int i=1;i<len_2;++i) {if (P[i]-1>len) {len=p[i]-1; Pos=i; }} if (LEN<2) cout<< "No solution!" <<endl; else{int mid,l,r; if (pos%2) {l=pos-(len-1); l/=2; --l; r=pos+ (len-1); r/=2; --r; }else{MID=POS/2; l=mid-len/2-1; r=mid+len/2-1; } cout<<l<< "" <<r<<endl; for (int i=pos-len;i<=pos+len;++i) {if (tran[i]!= ' # ') {char c= (tran[i]-k); if (c< ' a ') c+=26; cout<<c; }} cout<<endl; }}int Main () {Ios::sync_with_stdio (false); while (CIN>>BASC>>STR) {Manaler (); } return 0;}`

HDU 3294 Girls ' Manaler algorithm