P8040 [COCI 2016/2017 #7] IGRA
Background
Mirko and Slavko are very bored with their ski trip, so they start playing a new game.
Description
First, Mirko chooses an integer $N$, then Slavko writes down $N$ letters, and Mirko writes down a word of length $N$. Slavko needs to use the $N$ letters he wrote down to form a word, and in his word, there must be no position where the letter is the same as the letter in the corresponding position of Mirko’s word. To make the game challenging, Mirko also requires that Slavko’s word be the lexicographically smallest among all words that satisfy the requirement. This word **is guaranteed to exist**. Since Mirko and Slavko are still young, they only know the three letters `a`, `b`, and `c`, so the words they write will also contain only these three letters.
Please help Slavko find such a word.
Input Format
The first line contains an integer $N$, the number of letters in the words written by Mirko and Slavko.
The second line contains a string of length $N$, representing all the letters included in the word written by Slavko.
The third line contains a string of length $N$, representing the word written by Mirko.
Output Format
Output one line with a string of length $N$, the lexicographically smallest string that satisfies the requirement.
For two strings $a, b$ of length $N$, $a$ is lexicographically smaller than $b$ if and only if there exists an integer $p\in[1,N]$ such that $\forall i\in[1,p)$, $a_i=b_i$, and $a_p
Explanation/Hint
**Constraints**
For $40\%$ of the testdata, $1\leqslant N\leqslant 20$.
For all testdata, $1\leqslant N\leqslant 5000$, and all strings can only contain the letters `a`, `b`, `c`.
**Source**
This problem comes from **_[COCI 2016-2017](https://hsin.hr/coci/archive/2016_2017/) [CONTEST 7](https://hsin.hr/coci/archive/2016_2017/contest7_tasks.pdf) T3 IGRA_**. With the original testdata configuration, the full score is $100$ points.
Translated and organized by [Eason_AC](https://www.luogu.com.cn/user/112917).
Translated by ChatGPT 5