#include using namespace std; using ll = long long; #define dbl long double #define vec vector #define um unordered_map #define us unordered_set using ull = unsigned long long; using vi = vec; using vl = vector; using vd = vector; using pii = pair; using pll = pair; using pdd = pair; const vec indices = {{7,4}, {7,1}, {4,1}, {1,1}, {1,4}, {1,7}, {4,7}, {7,7}}; vec poss = { {-1,-1,-1,-1,-1,-1,-1,-1,-1}, {-1, 3,-1,-1, 4,-1,-1, 5,-1}, {-1,-1, 3,-1, 4,-1, 5,-1,-1}, {-1,-1,-1, 3, 4, 5,-1,-1,-1}, {-1, 2, 2, 2,-1, 6, 6, 6,-1}, {-1,-1,-1, 1, 0, 7,-1,-1,-1}, {-1,-1, 1,-1, 0,-1, 7,-1,-1}, {-1, 1,-1,-1, 0,-1,-1, 7,-1}, {-1,-1,-1,-1,-1,-1,-1,-1,-1}}; map char_to_pos = { {0,{0,1}}, {1,{0,2}}, {2,{0,3}}, {3,{0,4}}, {4,{0,5}}, {5,{0,6}}, {6,{0,7}}, {7,{1,2}}, {8,{1,3}}, {9,{4,6}}, {10,{1,4}}, {11,{1,5}}, {12,{1,6}}, {13,{1,7}}, {14,{2,3}}, {15,{2,4}}, {16,{2,5}}, {17,{2,6}}, {18,{2,7}}, {19,{3,4}}, {20,{3,5}}, {21,{4,7}}, {22,{5,6}}, {23,{5,7}}, {24,{3,6}}, {25,{6,7}}}; map pos_to_char; void init() { for (auto &&[char1, pos1] : char_to_pos) { pos_to_char.emplace(pos1, char1); } } void print_cell(int row, int col, int index) { auto &&[begin, end] = char_to_pos.at(index); if (row == 4 && col == 4) {cout<<'*';return;} int exp = poss[row][col]; if (exp == begin || exp == end) {cout << '#';} else {cout << '.';} } int main(){ init(); cin.sync_with_stdio(false); cin.tie(0); cin.exceptions(ios::failbit); int n, c; cin >> n >> c; vi encrypted; //cout << n << ", " << c << endl; for (int i = 0; i < n; i++) { vec orig(9); for (auto &&line : orig) cin >> line; int begin = 0; while (true) { auto && [row, col] = indices[begin]; if (orig[row][col] == '#') { //cout << "Found " << begin << endl; break; } begin++; } int end = begin + 1; while (true) { //cout << "End = " << end << endl; auto && [row, col] = indices[end]; if (orig[row][col] == '#') { break; } end++; } encrypted.push_back((pos_to_char.at(pii{begin, end}) + c) % 26); } for (int x : encrypted) { for (int row = 0; row < 9; row++) { for (int col = 0; col < 9; col++) { print_cell(row, col, x); } cout << endl; } } }