#include using namespace std; #define rep(i, a, b) for(int i = a; i < (b); ++i) #define all(x) begin(x), end(x) #define sz(x) (int)(x).size() typedef long long ll; typedef pair pii; typedef vector vi; typedef vector> vvi; typedef vector> vpii; template using vec = vector; template using uset = unordered_set; template using umap = unordered_map; constexpr array letterToNum = { 56, 57, 05, 15, 25, 35, 45, 67, 06, 13, 16, 26, 36, 46, 07, 17, 27, 37, 47, 01, 02, 14, 23, 24, 03, 34 }; void solve () { int N, C; cin >> N >> C; array sign; rep(i, 0, N) { for (auto & s : sign) cin >> s; vi nums; if (sign[3][3] == '#') nums.push_back(0); if (sign[3][4] == '#') nums.push_back(1); if (sign[3][5] == '#') nums.push_back(2); if (sign[4][5] == '#') nums.push_back(3); if (sign[5][5] == '#') nums.push_back(4); if (sign[5][4] == '#') nums.push_back(5); if (sign[5][3] == '#') nums.push_back(6); if (sign[4][3] == '#') nums.push_back(7); assert(sz(nums) == 2); auto [a, b] = minmax(nums.front(), nums.back()); int origCode = a*10 + b; int index = distance(letterToNum.begin(), find(all(letterToNum), origCode)); assert(index >= 0 && index < 26); // cerr << (char)(index + 'a') << endl; int cypherChar = (index + C) % 26; int cypherCode = letterToNum[cypherChar]; int dirA = cypherCode / 10, dirB = cypherCode % 10; rep(j, 1, 8) { rep(k, 1, 8) { sign[j][k] = '.'; } } sign[4][4] = '*'; for (auto dir : { dirA, dirB }) { auto [dx, dy] = array{ pii { -1, -1 }, pii { 0, -1 }, pii { 1, -1 }, pii { 1, 0 }, pii { 1, 1 }, pii { 0, 1 }, pii { -1, 1 }, pii { -1, 0 } }[dir]; rep(j, 0, 3) sign[4 + (j+1)*dy][4 + (j+1)*dx] = '#'; } for (auto & s : sign) cout << s << endl; } } int main() { cin.tie(0)->sync_with_stdio(0); cin.exceptions(cin.failbit); ll T = 1; //cin >> T; rep(i, 0, T) solve(); return 0; }