import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop;

void main() {
    auto L = readln.chomp.to!int;
    auto S = readln.chomp;
    auto T = readln.chomp;
    if (S > T) swap(S, T);
    if (S != T && T.startsWith(S)) {
        for (int s = 0, t = 0; t < T.length; s = (s+1)%(S.length.to!int), ++t) {
            if (S[s] > T[t]) {
                swap(S, T);
                break;
            }
        }
    }

    int a = S.length.to!int;
    int b = T.length.to!int;

    int use_s = 0;
    foreach (i; 0..L/a+10) {
        int by = (L - a * i);
        if (by >= 0 && by % b == 0)
            use_s = i;
    }

    string ans = "";
    foreach (i; 0..use_s) {
        ans ~= S;
    }
    while (ans.length < L) {
        ans ~= T;
    }

    ans.writeln;
}
