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, core.stdc.string;

bool check(string S, string T) {
    while (!S.empty && !T.empty) {
        if (S.length > T.length) {
            swap(S, T);
        }
        if (T.startsWith(S)) {
            T = T[S.length..$];
        } else {
            return false;
        }
    }
    return true;
}

void main() {
    auto N = readln.chomp.to!int;
    auto S = readln.chomp;
    auto T = readln.chomp;

    bool loop = check(S, T);

    for (int i = 0, j = 0; !loop; i = (i + 1) % S.length.to!int, j = (j + 1) % T.length.to!int) {
        if (S[i] < T[j]) {
            break;
        } else if (S[i] > T[j]) {
            swap(S, T);
            break;
        }
    }

    int X = (N - 1) / S.length.to!int + 1;
    X = X * S.length.to!int;
    while (X > N || (N - X) % T.length != 0) {
        X -= S.length.to!int;
    }

    string ans = "";
    while (ans.length < X) ans ~= S;
    while (ans.length < N) ans ~= T;

    ans.writeln;
}
