No tags yet

No tag edit access

The problem statement has recently been changed. View the changes.

×
time limit per test: 0.25 sec.

memory limit per test: 65536 KB

memory limit per test: 65536 KB

input: standard

output: standard

output: standard

The string is called permutative if it consists of N first capital letters in arbitrary order (i.e. "A", "BA", "CABED", "DCBA" for N=1, 2, 5, 4 correspondingly). The string is called almost permutative, if it is possible to obtain permutative string from it by removing exactly one symbol (i.e. "BA", "ABCCD", "BCAB", "ATB" -- almost permutative strings for N=1, 4, 3, 2 correspondingly). The string is called hyper almost permutative for some given N, if all its substrings of length N+1 are almost permutative (i.e. "ABCBACB", "ABCTABC", "CBACAB" -- hyper almost permutative strings for N=3).

Your task is to find the shortest hyper almost permutative string, containing permutative strings S1 and S2 as substrings for some given N. Strings S1 and S2 have the length N. The resulting string should be hyper almost permutative for the same given N.

Your task is to find the shortest hyper almost permutative string, containing permutative strings S1 and S2 as substrings for some given N. Strings S1 and S2 have the length N. The resulting string should be hyper almost permutative for the same given N.

The first line of the input file contains the integer number N (2 <= N <= 26). The second line contains the permurtative string S1. The third line contains the permurtative string S2. You can assume that S1 and S2 are different.

Write to the output file the answer for the problem. If there are several possible answers, output any of them.

Input

3

ABC

ACB

ABC

ACB

Output

ABCACB

Author: | Andrew V. Lazarev |

Resource: | ACM ICPC 2004-2005, NEERC, Southern Subregional Contest |

Date: | Saratov, October 7, 2004 |

Codeforces (c) Copyright 2010-2021 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Jun/14/2021 06:50:15 (h1).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|