Niuniu has recently learned LCS(Longest Common Subsequence) of two sequences.
Now he wants to know the LCS of four sequences.
Given 4 sequences {ai}, {bi}, {ci}, {di}.Please find the longest common subsequence.
The first line contains one integer, which is n.
The second line contains n integers, which is the sequence {ai}.
The third line contains n integers, which is the sequence {bi}.
The fourth line contains n integers, which is the sequence {ci}.
The fifth line contains n integers, which is the sequence {di}.
1 <= n <= 10000
1 <= ai <= n
Any number appears in {ai} at most 2 times.
1 <= bi <= n
Any number appears in {bi} at most 2 times.
1 <= ci <= n
Any number appears in {ci} at most 2 times.
1 <= di <= n
You should output one integer, which is the length of the LCS.
5 1 2 1 2 3 1 2 3 1 2 3 1 2 1 2 1 2 1 2 1
4

这道题你会答吗?花几分钟告诉大家答案吧!