English · Original
Chinese · Translation
Formal · Original
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.
On 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.
Well, 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_.
For 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.
## Input
The 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.
The 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.
The 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.
## Output
Output _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.
Input guarantees that such permutation exists.
[samples]
## Note
In the first sample, both 1, 2, 5, 4, 3 and 1, 2, 3, 4, 5 are acceptable outputs.
In the second sample, 5, 4, 2, 3, 1 is the only permutation to satisfy the constraints.
Sengoku 仍然记得她和 Lala-chan 小时候发现的神秘的“彩色流星体”。特别是其中一夜给她留下了深刻印象,让她产生了一种所有幻想都将实现的错觉。
那一夜,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$。
她几乎拥有一切——序列 $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$。
目前,Sengoku 能够通过天文记录恢复实际的颜色序列 $a$ 和 $b$,但她的愿望早已被遗忘。你需要重构出 Sengoku 当晚可能拥有的任意一个排列。
输入的第一行包含一个正整数 $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$ 个空格分隔的整数 $p_1, p_2, \dots, p_n$,表示 Sengoku 可能拥有的一个排列。如果存在多个可能的答案,请输出其中任意一个。
输入保证这样的排列存在。
在第一个样例中,$[1, 2, 5, 4, 3]$ 和 $[1, 2, 3, 4, 5]$ 都是可接受的输出。
在第二个样例中,$[5, 4, 2, 3, 1]$ 是唯一满足约束的排列。
## Input
输入的第一行包含一个正整数 $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$。
## Output
请输出 $n$ 个空格分隔的整数 $p_1, p_2, \dots, p_n$,表示 Sengoku 可能拥有的一个排列。如果存在多个可能的答案,请输出其中任意一个。输入保证这样的排列存在。
[samples]
## Note
在第一个样例中,$[1, 2, 5, 4, 3]$ 和 $[1, 2, 3, 4, 5]$ 都是可接受的输出。在第二个样例中,$[5, 4, 2, 3, 1]$ 是唯一满足约束的排列。
**Definitions**
Let $ n \in \mathbb{Z} $, $ n \geq 2 $.
Let $ 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 $.
Let $ P = (p_1, p_2, \dots, p_n) $ be a permutation of $ \{1, 2, \dots, n\} $.
**Constraints**
1. There exists exactly one index $ i \in \{1, \dots, n\} $ such that $ a_i \neq p_i $.
2. There exists exactly one index $ j \in \{1, \dots, n\} $ such that $ b_j \neq p_j $.
3. $ A \neq B $.
**Objective**
Find any permutation $ P $ satisfying the above constraints.
API Response (JSON)
{
"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 a...",
"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$ 颗流星,...",
"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 $...",
"is_translate": false,
"language": "Formal"
}
]
}