atcoder#RELAY2G. Coinage

Coinage

Score : 100100 points

Problem Statement

You are given two strings ss and tt consisting of lowercase English letters and an integer LL.

We will consider generating a string of length LL by concatenating one or more copies of ss and tt. Here, it is allowed to use the same string more than once.

For example, when s=s = at,, t=t = code and L=6,L = 6, the strings atatat,, atcode and codeat can be generated.

Among the strings that can be generated in this way, find the lexicographically smallest one. In the cases given as input, it is always possible to generate a string of length LL.

Constraints

  • 1L2×1051 \leq L \leq 2 \times 10^5
  • 1s,tL1 \leq |s|, |t| \leq L
  • ss and tt consist of lowercase English letters.
  • It is possible to generate a string of length LL in the way described in Problem Statement.

Input

Input is given from Standard Input in the following format:

NN

x1x_1 s1s_1

x2x_2 s2s_2

::

xNx_N sNs_N

Output

Print the lexicographically smallest string among the ones that can be generated in the way described in Problem Statement.

6
at
code
atatat

This input corresponds to the example shown in Problem Statement.

8
coding
festival
festival

It is possible that either ss or tt cannot be used at all in generating a string of length LL.

8
same
same
samesame

It is also possible that s=ts = t.

10
coin
age
ageagecoin