e-olymp
Competitions

Sequences + Longest Common Subsequence

Three sequences

Three sequences of integers are given. Find their longest common subsequence.

Input

Contains the description of three sequences. Each sequence in given with two lines. The first line contains the length of the sequence n (1n100), and the second line contains its elements (32 bits integers).

Output

Print the length of the longest common subsequence.

Time limit 1 seconds
Memory limit 128 MiB
Input example #1
3
1 2 3
3
1 3 2
3
2 1 3
Output example #1
2
Input example #2
3
1 2 3
3
4 5 6
3
1 3 5
Output example #2
0