#include using namespace std; #define int long long vector> dirs = { {1, 0}, {1, -1}, {0, -1}, {-1, -1}, {-1, 0}, {-1, 1}, {0, 1}, {1, 1} }; #define iD 0 #define iDL 1 #define iL 2 #define iTL 3 #define iT 4 #define iTR 5 #define iR 6 #define iDR 7 #define bD (1 << iD) #define bDL (1 << iDL) #define bL (1 << iL) #define bTL (1 << iTL) #define bT (1 << iT) #define bTR (1 << iTR) #define bR (1 << iR) #define bDR (1 << iDR) vector> a2b = { {iD, iDL}, {iD, iL}, {iD, iTL}, {iD, iT}, {iD, iTR}, {iD, iR}, {iD, iDR}, {iDL, iL}, {iDL, iTL}, {iT, iR}, {iDL, iT}, {iDL, iTR}, {iDL, iR}, {iDL, iDR}, {iL, iTL}, {iL, iT}, {iL, iTR}, {iL, iR}, {iL, iDR}, {iTL, iT}, {iTL, iTR}, {iT, iDR}, {iR, iTR}, {iTR, iDR}, {iTL, iR}, {iR, iDR}, }; /* D DL D L D TL D T D TR D R D DR DL L DL TL T R DL T DL TR DL R DL DR L TL L T L TR L R L DR TL T TL TR T DR R TR TR DR TL R R DR */ vector b2a(512); vector def = { ".........", ".........", ".........", ".........", "....*....", ".........", ".........", ".........", ".........", }; void print(vector& b) { vector ret = def; for(int idx : b) { auto [dy, dx] = dirs[idx]; for(int i = 1; i <= 3; i++) ret[4 + i * dy][4 + i * dx] = '#'; } for(int i = 0; i < 9; i++) cout << ret[i] << '\n'; } void _solve(int c) { vector ch(9); for(int i = 0; i < 9; i++) cin >> ch[i]; int bin = 0; for(int i = 0; i < 8; i++) { auto [dy, dx] = dirs[i]; if(ch[4 + dy][4 + dx] == '#') bin |= 1 << i; } int a = b2a[bin]; a = (a + c) % 26; vector b = a2b[a]; print(b); } void solve() { int n, c; cin >> n >> c; for(int i = 0; i < n; i++) _solve(c); } int32_t main() { b2a[bD | bDL] = 0; b2a[bD | bL] = 1; b2a[bD | bTL] = 2; b2a[bD | bT] = 3; b2a[bD | bTR] = 4; b2a[bD | bR] = 5; b2a[bD | bDR] = 6; b2a[bDL | bL] = 7; b2a[bDL | bTL] = 8; b2a[bT | bR] = 9; b2a[bDL | bT] = 10; b2a[bDL | bTR] = 11; b2a[bDL | bR] = 12; b2a[bDL | bDR] = 13; b2a[bL | bTL] = 14; b2a[bL | bT] = 15; b2a[bL | bTR] = 16; b2a[bL | bR] = 17; b2a[bL | bDR] = 18; b2a[bTL | bT] = 19; b2a[bTL | bTR] = 20; b2a[bT | bDR] = 21; b2a[bR | bTR] = 22; b2a[bTR | bDR] = 23; b2a[bTL | bR] = 24; b2a[bR | bDR] = 25; ios::sync_with_stdio(false); cin.tie(0); solve(); return 0; }