{"problem":{"name":"Make Same Set","description":{"content":"You are given three integer sequences of length $N$: $A=(A_1,A_2,\\dots,A_N),B=(B_1,B_2,\\dots,B_N),C=(C_1,C_2,\\dots,C_N)$. Find one set of integers that satisfies the following conditions. *   It can ","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":4000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"arc156_f"},"statements":[{"statement_type":"Markdown","content":"You are given three integer sequences of length $N$: $A=(A_1,A_2,\\dots,A_N),B=(B_1,B_2,\\dots,B_N),C=(C_1,C_2,\\dots,C_N)$.\nFind one set of integers that satisfies the following conditions.\n\n*   It can be obtained as follows: start with an empty set, and for each $i=1,2,\\dots,N$ in this order, add $A_i$ or $B_i$ to the set.\n*   It can be obtained as follows: start with an empty set, and for each $i=1,2,\\dots,N$ in this order, add $A_i$ or $C_i$ to the set.\n*   It has the maximum number of elements among the sets that satisfy the two conditions above.\n\n## Constraints\n\n*   $1 \\leq N \\leq 5000$\n*   $1 \\leq A_i,B_i,C_i \\leq 10000$\n*   All values in the input are integers.\n\n## Input\n\nThe input is given from Standard Input in the following format:\n\n$N$\n$A_1$ $A_2$ $\\dots$ $A_N$\n$B_1$ $B_2$ $\\dots$ $B_N$\n$C_1$ $C_2$ $\\dots$ $C_N$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"arc156_f","tags":[],"sample_group":[["3\n1 1 1\n2 3 4\n5 4 2","3\n4 1 2\n\nFor the set $\\lbrace 1,2,4\\rbrace$, we have the following.\n\n*   The first condition is satisfied because you can add $B_1,A_2,B_3$ to an empty set to obtain this set.\n*   The second condition is satisfied because you can add $A_1,C_2,C_3$ to an empty set to obtain this set.\n\nClearly, any set satisfying these conditions has at most $N=3$ elements, so this set also satisfies the third condition."],["15\n1 1 15 11 13 7 7 1 6 1 5 7 4 9 8\n11 30 1 18 16 15 19 17 3 27 22 7 21 29 9\n24 14 23 17 18 16 9 12 10 5 26 29 20 19 11","12\n7 9 11 17 19 1 15 4 5 6 29 13"]],"created_at":"2026-03-03 11:01:14"}}