#P8020. [ONTAK2015] Badania naukowe
[ONTAK2015] Badania naukowe
Problem Description
Given three digit strings , find a longest common subsequence of and such that is a substring of this subsequence.
Input Format
The first line contains an integer , the length of .
The second line contains integers, representing the digit string .
The third line contains an integer , the length of .
The fourth line contains integers, representing the digit string .
The fifth line contains an integer , the length of .
The sixth line contains integers, representing the digit string .
Output Format
Output one line with one integer. If there is no solution, output ; otherwise, output the length of the longest common subsequence that satisfies the condition.
7
1 2 2 3 1 1 2
6
1 2 1 3 1 2
2
3 2
4
Hint
For of the testdata, , .
Translated by ChatGPT 5