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;

bool same(string s, string t) {
    if (!t.startsWith(s)) return false;
    if (s.map!(c => s[0]==c).all && t.map!(c => t[0]==c).all && s[0]==t[0]) return true;
    if (t.length % s.length == 0) {
        s = s.repeat.take(t.length/s.length).join("");
        return s == t;
    }
    return false;
}


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

    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;
}
