---
{"languages_supported":{"0":"NA"},"title":"C5","category":"NA","old_version":true,"problem_code":"C5","tags":{"0":"NA"},"layout":"problem"}
---
<h3> All submissions for this problem are available. </h3><p> For two given sequences of integers, find the longest possible integer sequence which is a subsequence of both these sequences, and whose elements are integers in a (strictly) increasing order.</p>
<h3>Input</h3>
<p> The first number is n (1 ≤ n ≤ 5000), the length of the first sequence.</p>
<p> The next n integers are elements of the first sequence.</p>
<p> The next is m (1 ≤ m ≤ 5000), the length of the second sequence.</p>
<p> The next m integers are elements of the second sequence.</p>
<h3>Output</h3>
<p>One number k, the length of the longest possible common subsequence that is increasing, followed by exactly k space-separated integers containing any exemplary sequence of this length.</p>
<h3>Example</h3>
<p>For the input:
<pre>5
2 3 1 4 0
6
10 3 4 1 0 0
</pre>
the unique correct answer is:
<pre>2
3 4</pre></p>