#include <iostream>
#include <vector>
using namespace std;
typedef pair<int, int> pii;
const int N = 32000, M = 70, K = 15;
int m = 55 + 12;
int l[N], r[N], u[N], d[N], row[N], col[N], idx;
int cnt[M];
int ans[K], top;
char g[K][K];
int id[K][K];
bool st[K];
struct Op
{
char c;
vector<pii> points;
} op[N];
string blk[12][4] = {
{
"**",
"* "
},
{
"****",
" ",
" ",
" "
},
{
"***",
"* ",
" "
},
{
"**",
"**"
},
{
"* ",
"* ",
"***"
},
{
"****",
" * ",
" ",
" "
},
{
"***",
"* *",
" "
},
{
"***",
"** ",
" "
},
{
"*** ",
" **",
" ",
" "
},
{
" * ",
"***",
" * "
},
{
"* ",
"** ",
" **"
},
{
"****",
"* ",
" ",
" "
}
};
int blk_state[12] = {1, 1, 0, 2, 1, 0, 1, 0, 0, 2, 1, 0};
void init()
{
for (int i = 0; i <= m; i++) {
l[i] = i - 1, r[i] = i + 1;
u[i] = d[i] = col[i] = i;
cnt[i] = 0;
}
l[0] = m, r[m] = 0;
idx = m + 1;
}
void add(int hh, int &tt, int x, int y)
{
row[idx] = x, col[idx] = y, cnt[y]++;
l[idx] = tt, r[idx] = hh, l[hh] = idx, r[tt] = idx;
u[idx] = u[y], d[idx] = y, d[u[y]] = idx, u[y] = idx;
tt = idx++;
}
void remove(int p)
{
r[l[p]] = r[p], l[r[p]] = l[p];
for (int i = d[p]; i != p; i = d[i])
for (int j = r[i]; j != i; j = r[j]) {
cnt[col[j]]--;
u[d[j]] = u[j], d[u[j]] = d[j];
}
}
void resume(int p)
{
for (int i = u[p]; i != p; i = u[i])
for (int j = l[i]; j != i; j = l[j]) {
u[d[j]] = j, d[u[j]] = j;
cnt[col[j]]++;
}
r[l[p]] = p, l[r[p]] = p;
}
bool dfs()
{
if (!r[0]) return true;
int p = r[0];
for (int i = r[0]; i; i = r[i])
if (cnt[i] < cnt[p])
p = i;
remove(p);
for (int i = d[p]; i != p; i = d[i]) {
ans[++top] = row[i];
for (int j = r[i]; j != i; j = r[j]) remove(col[j]);
if (dfs()) return true;
for (int j = l[i]; j != i; j = l[j]) resume(col[j]);
top--;
}
resume(p);
return false;
}
void mirror(int u)
{
auto &s = blk[u];
int len = s[0].size();
for (int i = 0; i < len; i++)
for (int j = 0, k = len - 1; j < k; j++, k--)
swap(s[i][j], s[i][k]);
}
void rotate(int u)
{
mirror(u);
auto &s = blk[u];
int len = s[0].size();
for (int i = 0; i < len; i++)
for (int j = 0; j < i; j++)
swap(s[i][j], s[j][i]);
}
vector<pii> get(int u, int a, int b, bool &flag)
{
flag = true;
vector<pii> res;
auto &s = blk[u];
int len = s[0].size();
for (int i = 0; i < len; i++)
for (int j = 0; j < len; j++)
if (s[i][j] == '*') {
int x = i + a, y = j + b;
if (x < 0 || x >= 10 || y < 0 || y >= 10 || g[x][y] != '.') {
flag = false;
return {};
}
res.push_back({x, y});
}
return res;
}
int main()
{
ios::sync_with_stdio(false);
for (int i = 0; i < 10; i++) cin >> g[i];
for (int i = 0, k = 1; i < 10; i++)
for (int j = 0; j <= i; j++)
id[i][j] = k++;
init();
int n = 0;
for (int u = 0; u < 12; u++) {
int hh = idx, tt = idx;
for (int i = 0; i < 10; i++)
for (int j = 0; j <= i; j++)
if (g[i][j] == u + 'A') {
if (!st[u]) st[u] = true, n++;
add(hh, tt, n, id[i][j]);
}
if (st[u]) add(hh, tt, n, u + 56);
}
for (int u = 0; u < 12; u++) {
if (st[u]) continue;
for (int i = 0; i < (!blk_state[u] ? 2 : 1); i++) {
for (int j = 0; j < (blk_state[u] != 2 ? 4 : 1); j++) {
for (int a = -1; a < 9; a++)
for (int b = -2; b < min(a + 1, 9); b++) {
bool isvalid;
auto t = get(u, a, b, isvalid);
if (isvalid) {
int hh = idx, tt = idx;
op[++n] = {u + 'A', t};
for (auto &[x, y] : t)
add(hh, tt, n, id[x][y]);
add(hh, tt, n, u + 56);
}
}
rotate(u);
}
mirror(u);
}
}
if (dfs()) {
for (int i = 1; i <= top; i++) {
char c = op[ans[i]].c;
for (auto &[x, y] : op[ans[i]].points) g[x][y] = c;
}
for (int i = 0; i < 10; i++) cout << g[i] << endl;
}
else cout << "No solution";
return 0;
}