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

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


	int veci, manji;
	if(a1>=a2) 
		{ veci=a1; manji=a2;}
	else 	   
		{ veci=a2; manji=a1;}


	//Bazni slucajevi
	if ((c1==c2) || (veci - manji > 1)) { cout<< "nemoguce" << endl; return 0; }

	else {
		vector<char> v(a1+a2);
		if(a1==veci) {
			while(a1!=1)
			{
				v.push_back(c1);
				v.push_back(c2);
				a1--;
				a2--;
			}
			v.push_back(c1);
		}
		else
			if(a2==veci) {
			while(a2!=1)
			{
				v.push_back(c2);
				v.push_back(c1);
				a1--;
				a2--;
			}
			v.push_back(c2);	
		}
		for (auto i = v.begin(); i != v .end(); ++i)
    	cout <<*i;
	}

	return 0;

}