15011501 SUSTech Online Judge
Problem 1501 --Common Palindrome String

1501: Common Palindrome String

Time Limit: 4 Sec  Memory Limit: 128 MB
Submit: 3477  Solved: 206
[Submit][Status][Web Board]

Description

A string is called a palindrome string if the reverse of that string is the same as the original string.

Given two strings \(A\) and \(B\), please find out the length of the longest common palindrome substring of \(A\) and \(B\). If \(A\) and \(B\) do not have a common palindrome substring, print out -1.

Input

The input contains two lines, which are \(A\) and \(B\) respectively\((1\le |A|, |B| \le 300000)\). \(A\) and \(B\) only contain lower English letters.

Output

Print out the answer in a single line.

Sample Input

abababa
bababab

Sample Output

5

HINT

Source

 

[Submit][Status]