#include <iostream>
#include <string>
#define MIN_NUM 1
#define MAX_NUM 50000

using namespace std;

int main()
{
    char c1, c2;
    int a1, a2;
    string str;

    /// Unos slova. Primer: ab
    getline(cin, str);
    while(true){
        if(str.size() == 2 && str[0] >= 'a' && str[0] <='z' && str[1] >= 'a' && str[1] <='z' && str[0] != str[1]){
            break;
        }else{
            cout << "Pogresan unos, pokusaj opet: ";
            getline(cin, str);
        }
    }

    c1 = str[0];
    c2 = str[1];
    str = "";

    /// Unos brojeva. Primer: 3 2
    getline(cin, str);
    while(true){
        bool uspesno = false;

        char counter = 1;
        size_t found = -1;
        while(true){
            found  = str.find(' ', found + 1);
            if(found != string::npos){
                counter++;
            }else{
                break;
            }
        }

        if(counter == 2){
            sscanf(str.c_str(), "%d %d", &a1, &a2);

            uspesno = ((a1 >= MIN_NUM && a1 <= MAX_NUM) && ((a2 >= MIN_NUM && a2 <= MAX_NUM))) ? true : false;
        }

        if(!uspesno){
            cout << "Pogresan unos, pokusaj opet: ";
            getline(cin, str);
        }else{
            break;
        }
    }

    /// Izlaz
    if(a1 == a2 || a1 == a2 + 1){
        for(int i = 0; i < a1 + a2; i++){
            cout << ((i % 2 == 0) ? c1 : c2);
        }
    }else if(a2 == a1 + 1){
        for(int i = 0; i < a1 + a2; i++){
            cout << ((i % 2 == 0) ? c2 : c1);
        }
    }else{
        cout << "nemoguce";
    }

    return 0;
}