#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (a) - 1; i >= (b); i--)
#define SZ(a) int(a.size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair
#define F first
#define S second
typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef double db;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int r, n;
cin >> r >> n;
vector<string> rows(r + 3);
VI cntEmpty(r + 3);
int cntLeft = 0, cntRight = 0;
FOR(i, 0, r + 3)
{
cin >> rows[i];
assert(SZ(rows[i]) == 11);
FOR(j, 0, 11)
{
if (rows[i][j] == '-')
{
if (j < 5)
cntLeft++;
else if (j > 5)
cntRight++;
cntEmpty[i]++;
}
}
}
VI exitRows = {0, r / 2 + 1, r + 2};
auto cmp = [&](int i, int j)
{
if (j == -1)
return true;
assert(cntEmpty[i] != 0 && cntEmpty[j] != 0);
bool afterExitI = false, afterExitJ = false;
for (int ex : exitRows)
{
afterExitI |= i == ex + 1;
afterExitJ |= j == ex + 1;
}
if (afterExitI ^ afterExitJ)
return afterExitI;
if (cntEmpty[i] != cntEmpty[j])
return cntEmpty[i] > cntEmpty[j];
int minDistI = r + 47, minDistJ = r + 47;
for (int ex : exitRows)
{
minDistI = min(minDistI, abs(ex - i));
minDistJ = min(minDistJ, abs(ex - j));
}
if (minDistI != minDistJ)
return minDistI < minDistJ;
return i < j;
};
VI distFromMid = {1, 3, 5, 0, 4};
for (char c = 'a'; c < 'a' + n; c++)
{
int bestRow = -1;
FOR(i, 0, r + 3)
{
if (cntEmpty[i] == 0)
continue;
if (cmp(i, bestRow))
bestRow = i;
}
cntEmpty[bestRow]--;
for (int d : distFromMid)
{
int le = 5 - d, ri = 5 + d;
bool freeLe = rows[bestRow][le] == '-', freeRi = rows[bestRow][ri] == '-';
if (!freeLe && !freeRi)
continue;
int seat;
if (!freeRi)
{
seat = le;
}
else if (!freeLe)
{
seat = ri;
}
else if (cntLeft >= cntRight)
{
seat = le;
}
else
seat = ri;
rows[bestRow][seat] = c;
if (d != 0)
{
if (seat == le)
cntLeft--;
else
cntRight--;
}
break;
}
}
for (string row : rows)
cout << row << "\n";
return 0;
}
sdgsd