#K16241. Interleaved Security Code Generation

    ID: 24535 Type: Default 1000ms 256MiB

Interleaved Security Code Generation

Interleaved Security Code Generation

In this problem, you are given two strings, (a) and (b), along with their lengths (n) and (m) respectively. Your task is to generate a security code by interleaving the two strings while preserving the relative order of characters in each string. Specifically, for each valid index (i) where (0 \leq i < \min(n, m)), the resulting code should contain (a[i]) followed by (b[i]). After interleaving up to the minimum length, the remaining characters (if any) from the longer string should be appended to the result.

For example, if (n = 3), (m = 3), (a = \texttt{ABC}) and (b = \texttt{def}), then the output should be (\texttt{AdBeCf}).

inputFormat

The input is provided via standard input (stdin) consisting of three lines:

  1. The first line contains two integers (n) and (m) separated by a space, indicating the lengths of strings (a) and (b), respectively.

  2. The second line contains the string (a), which consists of uppercase alphabets. If (n = 0), this line will be empty.

  3. The third line contains the string (b), which consists of lowercase alphabets. If (m = 0), this line will be empty.

outputFormat

Output the security code as a single string via standard output (stdout). This string is the result of interleaving (a) and (b) according to the rules described above.## sample

3 3
ABC
def
AdBeCf

</p>