using namespace std;
#include <bits/stdc++.h>

#include<string>

const int brojKaraktera = 50;

struct omnitriks {
    int ucestanost;
    char kar;

    bool operator < (const omnitriks & l) const {
        return ucestanost < l.ucestanost;
    }
};

void nesusedni(string str) {
    int n = str.length();

    int brojaC[brojKaraktera] = {
        0
    };
    for (int i = 0; i < n; i++)
        brojaC[str[i] - 'a']++;

    priority_queue < omnitriks > rp;
    for (char c = 'a'; c <= 'z'; c++) {
        int vred = c - 'a';
        if (brojaC[vred]) {
            rp.push(omnitriks {
                brojaC[vred], c
            });
        }
    }

    str = "";

    omnitriks prev {
        -1, '#'
    };

    while (!rp.empty()) {

        omnitriks l = rp.top();
        rp.pop();
        str = str + l.kar;

        if (prev.ucestanost > 0)
            rp.push(prev);

        (l.ucestanost) --;
        prev = l;
    }

    if (n != str.length())
        cout << " Nemoguce" << endl;

    else
        cout << str << endl;
}

int main() {
    char c1, c2;
    int a1, a2;
    cin >> c1;
    c1 = tolower(c1);
	cin >> c2;
	c2 = tolower(c2);
    cin >> a1;
    cin >> a2;

    string str = string(a1, c1) + string(a2, c2);
    nesusedni(str);

    return 0;
}