#include using namespace std; #define FOR(i, n) for(int i = 0; i < n; i++) int ABC = 26; vector> dir{ { ".........", ".........", ".........", ".........", "....*....", "....#....", "....#....", "....#....", "........." }, { ".........", ".........", ".........", ".........", "....*....", "...#.....", "..#......", ".#.......", "........." }, { ".........", ".........", ".........", ".........", ".###*....", ".........", ".........", ".........", "........." }, { ".........", ".#.......", "..#......", "...#.....", "....*....", ".........", ".........", ".........", "........." }, { ".........", "....#....", "....#....", "....#....", "....*....", ".........", ".........", ".........", "........." }, { ".........", ".......#.", "......#..", ".....#...", "....*....", ".........", ".........", ".........", "........." }, { ".........", ".........", ".........", ".........", "....*###.", ".........", ".........", ".........", "........." }, { ".........", ".........", ".........", ".........", "....*....", ".....#...", "......#..", ".......#.", "........." } }; vector> atop{ {0, 1}, {0, 2}, {0, 3}, {0, 4}, {0, 5}, {0, 6}, {0, 7}, {1, 2}, {1, 3}, {4, 6}, {1, 4}, {1, 5}, {1, 6}, {1, 7}, {2, 3}, {2, 4}, {2, 5}, {2, 6}, {2, 7}, {3, 4}, {3, 5}, {4, 7}, {5, 6}, {5, 7}, {3, 6}, {6, 7} }; int main() { int n, c; cin >> n >> c; FOR(i, n){ vector act; FOR(a, 9){ string s; cin >> s; if(a == 3){ if(s[3] == '#') act.push_back(3); if(s[4] == '#') act.push_back(4); if(s[5] == '#') act.push_back(5); } else if(a == 4){ if(s[3] == '#') act.push_back(2); if(s[5] == '#') act.push_back(6); } else if(a==5){ if(s[3] == '#') act.push_back(1); if(s[4] == '#') act.push_back(0); if(s[5] == '#') act.push_back(7); } } int ans = 0; FOR(i, 26){ if(make_pair(act[0], act[1]) == atop[i]){ ans = i; break; } else if(make_pair(act[1], act[0]) == atop[i]){ ans = i; break; } } ans += c; ans %= 26; FOR(i, 9) { FOR(j, 9){ if(dir[atop[ans].first][i][j] == '#' || dir[atop[ans].second][i][j] == '#'){ cout << '#'; } else cout << dir[atop[ans].first][i][j]; } cout << "\n"; } } }