{"trustable":true,"sections":[{"title":"","value":{"format":"HTML","content":"You are given two sequences of integer numbers. Write a program to determine their common increasing subsequence of maximal possible length. \r\u003cbr\u003eSequence S\u003csub\u003e1\u003c/sub\u003e , S\u003csub\u003e2\u003c/sub\u003e , . . . , S\u003csub\u003eN\u003c/sub\u003e of length N is called an increasing subsequence of a sequence A\u003csub\u003e1\u003c/sub\u003e , A\u003csub\u003e2\u003c/sub\u003e , . . . , A\u003csub\u003eM\u003c/sub\u003e of length M if there exist 1 \u0026lt;\u003d i\u003csub\u003e1\u003c/sub\u003e \u0026lt; i\u003csub\u003e2\u003c/sub\u003e \u0026lt; . . . \u0026lt; i\u003csub\u003eN\u003c/sub\u003e \u0026lt;\u003d M such that S\u003csub\u003ej\u003c/sub\u003e \u003d A\u003csub\u003ei\u003csub\u003ej\u003c/sub\u003e\u003c/sub\u003e for all 1 \u0026lt;\u003d j \u0026lt;\u003d N , and S\u003csub\u003ej\u003c/sub\u003e \u0026lt; S\u003csub\u003ej+1\u003c/sub\u003e for all 1 \u0026lt;\u003d j \u0026lt; N . "}},{"title":"Input","value":{"format":"HTML","content":"Each sequence is described with M --- its length (1 \u0026lt;\u003d M \u0026lt;\u003d 500) and M integer numbers A\u003csub\u003ei\u003c/sub\u003e (-2\u003csup\u003e31\u003c/sup\u003e \u0026lt;\u003d A\u003csub\u003ei\u003c/sub\u003e \u0026lt; 2\u003csup\u003e31\u003c/sup\u003e ) --- the sequence itself. "}},{"title":"Output","value":{"format":"HTML","content":"On the first line of the output file print L --- the length of the greatest common increasing subsequence of both sequences. On the second line print the subsequence itself. If there are several possible answers, output any of them. "}},{"title":"Sample","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e5\r\n1 4 2 5 -12\r\n4\r\n-12 1 2 4\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e2\r\n1 4\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}