11633 - I2P_EECS_MID1_2   

Description

Our aspiring and naughty professor HT Chen is so happy to see you guys having solved his "exquisite substring" problem !!

But he found that there was also another special attribute of strings he wrote down. 

He found that for any 2 string consisted by '0'to '9' , 'a' to 'z' and 'A' to 'Z', we can find a common longest substring (CLS) of them, which is belongs to the both sequences, continue, left to right, as long as possible and the length of substring might be 1.

For instance, the CLS of "aabbccdd" and "bbaaccdd" is "ccdd".

HT was wondering the length of the CLS for each pair string he wrote on the paper. Counting them by hand will be a dreadful work, so he decided to give it as one of the questions of your midterm. HT would be happy if you both getting your midterm score and solving his problem.

Input

There are multiple lines in each testcase. Every two lines contains a pair of strings that HT wrote on the paper.

The input file is ended by 'EOF'.

It is guaranteed that (s is a arbitrary string in corresponding testcase):

  • At most 10 pairs of lines in each testcase.
  • testcase #1 ~ #5 : 1 ≤ | s | ≤ 50
  • testcase #6 ~ #8 : 50 ≤ | s | ≤ 500
  • testcase #9 ~ #10 : 500 ≤ | s | ≤ 1000

For the last 2 testcases, try to recall the method for the bonus testcase of pE we had discussed on Monday.

Or you can try to complete the other 2 questions first then focusing on the 9th & 10th testcases.

 

 

Output

For each string pair si, please output a line contains one integer representing the length of CLS in si.

If there is not a CLS, please output 0.

(i.e. Please print '\n' after each answer.)

Sample Input  Download

Sample Output  Download

Tags




Discuss