{"problem":{"name":"B. An express train to reveries","description":{"content":"Sengoku still remembers the mysterious \"colourful meteoroids\" she discovered with Lala-chan when they were little. In particular, one of the nights impressed her deeply, giving her the illusion that a","description_type":"Markdown"},"platform":"Codeforces","limit":{"time_limit":1000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"CF814B"},"statements":[{"statement_type":"Markdown","content":"Sengoku still remembers the mysterious \"colourful meteoroids\" she discovered with Lala-chan when they were little. In particular, one of the nights impressed her deeply, giving her the illusion that all her fancies would be realized.\n\nOn that night, Sengoku constructed a permutation _p_1, _p_2, ..., _p__n_ of integers from 1 to _n_ inclusive, with each integer representing a colour, wishing for the colours to see in the coming meteor outburst. Two incredible outbursts then arrived, each with _n_ meteorids, colours of which being integer sequences _a_1, _a_2, ..., _a__n_ and _b_1, _b_2, ..., _b__n_ respectively. Meteoroids' colours were also between 1 and _n_ inclusive, and the two sequences were not identical, that is, at least one _i_ (1 ≤ _i_ ≤ _n_) exists, such that _a__i_ ≠ _b__i_ holds.\n\nWell, she almost had it all — each of the sequences _a_ and _b_ matched exactly _n_ - 1 elements in Sengoku's permutation. In other words, there is exactly one _i_ (1 ≤ _i_ ≤ _n_) such that _a__i_ ≠ _p__i_, and exactly one _j_ (1 ≤ _j_ ≤ _n_) such that _b__j_ ≠ _p__j_.\n\nFor now, Sengoku is able to recover the actual colour sequences _a_ and _b_ through astronomical records, but her wishes have been long forgotten. You are to reconstruct any possible permutation Sengoku could have had on that night.\n\n## Input\n\nThe first line of input contains a positive integer _n_ (2 ≤ _n_ ≤ 1 000) — the length of Sengoku's permutation, being the length of both meteor outbursts at the same time.\n\nThe second line contains _n_ space-separated integers _a_1, _a_2, ..., _a__n_ (1 ≤ _a__i_ ≤ _n_) — the sequence of colours in the first meteor outburst.\n\nThe third line contains _n_ space-separated integers _b_1, _b_2, ..., _b__n_ (1 ≤ _b__i_ ≤ _n_) — the sequence of colours in the second meteor outburst. At least one _i_ (1 ≤ _i_ ≤ _n_) exists, such that _a__i_ ≠ _b__i_ holds.\n\n## Output\n\nOutput _n_ space-separated integers _p_1, _p_2, ..., _p__n_, denoting a possible permutation Sengoku could have had. If there are more than one possible answer, output any one of them.\n\nInput guarantees that such permutation exists.\n\n[samples]\n\n## Note\n\nIn the first sample, both 1, 2, 5, 4, 3 and 1, 2, 3, 4, 5 are acceptable outputs.\n\nIn the second sample, 5, 4, 2, 3, 1 is the only permutation to satisfy the constraints.","is_translate":false,"language":"English"},{"statement_type":"Markdown","content":"Sengoku 仍然记得她和 Lala-chan 小时候发现的神秘的“彩色流星体”。特别是其中一夜给她留下了深刻印象，让她产生了一种所有幻想都将实现的错觉。\n\n那一夜，Sengoku 构造了一个由整数 $1$ 到 $n$ 组成的排列 $[p_1, p_2, \\dots, p_n]$，每个整数代表一种颜色，希望在即将到来的流星雨中看到这些颜色。随后，两场惊人的流星雨降临，每场都包含 $n$ 颗流星，其颜色分别由序列 $[a_1, a_2, \\dots, a_n]$ 和 $[b_1, b_2, \\dots, b_n]$ 表示。流星的颜色也在 $1$ 到 $n$ 之间，且这两个序列不完全相同，即至少存在一个 $i$（$1 \\le i \\le n$）使得 $a_i \\ne b_i$。\n\n她几乎拥有一切——序列 $a$ 和 $b$ 各自恰好与 Sengoku 的排列匹配了 $n-1$ 个元素。换句话说，恰好存在一个 $i$（$1 \\le i \\le n$）使得 $a_i \\ne p_i$，且恰好存在一个 $j$（$1 \\le j \\le n$）使得 $b_j \\ne p_j$。\n\n目前，Sengoku 能够通过天文记录恢复实际的颜色序列 $a$ 和 $b$，但她的愿望早已被遗忘。你需要重构出 Sengoku 当晚可能拥有的任意一个排列。\n\n输入的第一行包含一个正整数 $n$（$2 \\le n \\le 1\\,000$）——Sengoku 排列的长度，同时也是两次流星雨的长度。\n\n第二行包含 $n$ 个空格分隔的整数 $a_1, a_2, \\dots, a_n$（$1 \\le a_i \\le n$）——第一次流星雨的颜色序列。\n\n第三行包含 $n$ 个空格分隔的整数 $b_1, b_2, \\dots, b_n$（$1 \\le b_i \\le n$）——第二次流星雨的颜色序列。至少存在一个 $i$（$1 \\le i \\le n$）使得 $a_i \\ne b_i$。\n\n请输出 $n$ 个空格分隔的整数 $p_1, p_2, \\dots, p_n$，表示 Sengoku 可能拥有的一个排列。如果存在多个可能的答案，请输出其中任意一个。\n\n输入保证这样的排列存在。\n\n在第一个样例中，$[1, 2, 5, 4, 3]$ 和 $[1, 2, 3, 4, 5]$ 都是可接受的输出。\n\n在第二个样例中，$[5, 4, 2, 3, 1]$ 是唯一满足约束的排列。\n\n## Input\n\n输入的第一行包含一个正整数 $n$（$2 \\le n \\le 1\\,000$）——Sengoku 排列的长度，同时也是两次流星雨的长度。第二行包含 $n$ 个空格分隔的整数 $a_1, a_2, \\dots, a_n$（$1 \\le a_i \\le n$）——第一次流星雨的颜色序列。第三行包含 $n$ 个空格分隔的整数 $b_1, b_2, \\dots, b_n$（$1 \\le b_i \\le n$）——第二次流星雨的颜色序列。至少存在一个 $i$（$1 \\le i \\le n$）使得 $a_i \\ne b_i$。\n\n## Output\n\n请输出 $n$ 个空格分隔的整数 $p_1, p_2, \\dots, p_n$，表示 Sengoku 可能拥有的一个排列。如果存在多个可能的答案，请输出其中任意一个。输入保证这样的排列存在。\n\n[samples]\n\n## Note\n\n在第一个样例中，$[1, 2, 5, 4, 3]$ 和 $[1, 2, 3, 4, 5]$ 都是可接受的输出。在第二个样例中，$[5, 4, 2, 3, 1]$ 是唯一满足约束的排列。","is_translate":true,"language":"Chinese"},{"statement_type":"Markdown","content":"**Definitions**  \nLet $ n \\in \\mathbb{Z} $, $ n \\geq 2 $.  \nLet $ A = (a_1, a_2, \\dots, a_n) $, $ B = (b_1, b_2, \\dots, b_n) $ be two sequences of integers in $ \\{1, 2, \\dots, n\\} $, with $ A \\neq B $.  \nLet $ P = (p_1, p_2, \\dots, p_n) $ be a permutation of $ \\{1, 2, \\dots, n\\} $.\n\n**Constraints**  \n1. There exists exactly one index $ i \\in \\{1, \\dots, n\\} $ such that $ a_i \\neq p_i $.  \n2. There exists exactly one index $ j \\in \\{1, \\dots, n\\} $ such that $ b_j \\neq p_j $.  \n3. $ A \\neq B $.\n\n**Objective**  \nFind any permutation $ P $ satisfying the above constraints.","is_translate":false,"language":"Formal"}],"meta":{"iden":"CF814B","tags":["constructive algorithms"],"sample_group":[["5\n1 2 3 4 3\n1 2 5 4 5","1 2 5 4 3"],["5\n4 4 2 3 1\n5 4 5 3 1","5 4 2 3 1"],["4\n1 1 3 4\n1 4 3 4","1 2 3 4"]],"created_at":"2026-03-03 11:00:39"}}