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


void main() {
    int L;
    string s, t;

    scan(L);
    scan(s);
    scan(t);

    if (s > t) {
        swap(s, t);
    }

    if (s == t[0 .. s.length]) {
        string ss;
        string tt = t ~ t;

        while (ss.length < t.length) {
            ss ~= s;
        }

        if (ss > tt) {
            swap(s, t);
        }
    }

    int n = s.length.to!int;
    int m = t.length.to!int;

    int k = 0;
    int kk = 0;

    while (n * kk <=  L) {
        if ((L - n*kk) % m == 0) {
            k = kk;
        }
        kk++;
    }

    string ans;

    foreach (i ; 0 .. k) {
        ans ~= s;
    }

    foreach (i ; 0 .. (L - n*k) / m) {
        ans ~= t;
    }

    writeln(ans);
}


void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}