#### Registered Users Only

Please login to utilize this feature.

Do note that this website only supports submissions in C++.

## Problem Description

After arranging several movie going events, each fullfilling some seating constraints,

you realized that in some weeks, the seating arrangements that you made look very similar :O.

For example:

Last week, your group with **N** = 8 movie goers seat in this order: {1, 2, 3, 4, 5, 6, 7, 8}.

This week, your group with **M** = 9 movie goers seat in this order: {1, 2, 4, 3, 5, 6, 7, 8, 9}.

You have just studied the "Longest Common Subsequence" (LCS) problem few weeks ago and realized that the LCS between the two seating arrangements above is 7, very close to **N** = 8 and **M** = 9.

This is interesting, so you want to compare several seating arrangements that you have made in the past

to see if you have any specific pattern in arranging the seating plan of your movie going group.

## Input

For each testcase, the first line contains two integers **N** and **M** (1 <= **N, M** <= 50000).

The second line contains **N** different integers in the range **[1 .. N]**.

The third line contains **M** different integers in the range **[1 .. M]**.

## Output

For each test case, print the case number and the answer.

Look at the output for sample input for details.

## Sample Input 1

8 9 1 2 3 4 5 6 7 8 1 2 4 3 5 6 7 8 9

## Sample Output 1

7

## Sample Input 2

8 9 1 2 3 4 5 6 7 8 1 2 4 3 5 6 9 7 8

## Sample Output 2

7

## Acknowledgements

This problem is from CS3233 2011 Team Contest 2 Problem B. (which is modified from UVa 10635).

### Tags

### Subtasks and Limits

Subtask | Score | #TC | Time | Memory | Scoring |
---|---|---|---|---|---|

1 | 100 | 10 | 1s | 32MB | Average |

2 | 0 | 2 | 1s | 32MB | Average |

### Judge Compile Command

g++-8 ans.cpp -o movie -Wall -Wshadow -static -O2 -lm -m64 -s -w -std=gnu++17 -fmax-errors=512