#include using Picture = char[9][10]; void solve_letter(int c); void print_pic(const Picture &pic); char to_char(const Picture &pic); void to_pic(char c, Picture &pic); char shift(char c, char amt); void add_arm(int yi, int xi, Picture &pic); int letter_to_num[] = { 01, 02, 03, 04, 05, 06, 07, 12, 13, 46, 14, 15, 16, 17, 23, 24, 25, 26, 27, 34, 35, 47, 56, 57, 36, 67 }; int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); int n, c; std::cin >> n >> c; for (int i = 0; i < n; ++i) { solve_letter(c); } return 0; } void solve_letter(int C) { Picture pic; for (auto& row : pic) { std::cin >> row; } char chr = to_char(pic); chr = shift(chr, C); to_pic(chr, pic); print_pic(pic); } void print_pic(const Picture &pic) { for(const auto& row: pic) { std::cout << row << '\n'; } } char to_char(const Picture &pic) { constexpr char F = '#'; char pos[2]; int idx = 0; if (pic[5][4] == F) pos[idx++] = 0; if (pic[5][3] == F) pos[idx++] = 1; if (pic[4][3] == F) pos[idx++] = 2; if (pic[3][3] == F) pos[idx++] = 3; if (pic[3][4] == F) pos[idx++] = 4; if (pic[3][5] == F) pos[idx++] = 5; if (pic[4][5] == F) pos[idx++] = 6; if (pic[5][5] == F) pos[idx++] = 7; int num = pos[0] * 10 + pos[1]; char ret = 0; while (letter_to_num[ret] != num) ret++; return ret + 'A'; } void add_arm(int yi, int xi, Picture &pic) { int y = 4; int x = 4; for (int i = 0; i < 3; ++i) { y += yi; x += xi; pic[y][x] = '#'; } } void to_pic(char c, Picture &pic) { for (int j = 0; j < 9; ++j) { for (int i = 0; i < 9; ++i) { pic[j][i] = '.'; } pic[j][9] = '\0'; } pic[4][4] = '*'; int num = letter_to_num[c - 'A']; int pos[2] = { num / 10, num % 10 }; for (const auto &p : pos) { if (p == 0) add_arm(1, 0, pic); if (p == 1) add_arm(1, -1, pic); if (p == 2) add_arm(0, -1, pic); if (p == 3) add_arm(-1, -1, pic); if (p == 4) add_arm(-1, 0, pic); if (p == 5) add_arm(-1, 1, pic); if (p == 6) add_arm(0, 1, pic); if (p == 7) add_arm(1, 1, pic); } } char shift(char c, char amt) { constexpr char ALPH_LEN = 'Z' - 'A' + 1; constexpr char BEG = 'A'; return (c - BEG + amt) % ALPH_LEN + BEG; }