#include #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #define fi first #define se second #define int long long #define vec vector using namespace std; map p; void solve(int m) { vec a(9); for(int i = 0;i<9;i++) cin>>a[i]; string s = ""; for(int i = 3;i<=5;i++){ for(int j = 3;j<=5;j++) s+=a[i][j]; } //cout << p[s] << "\n"; char r = p[s] + m; if(r > 'Z'){ r -= 26; // cout << "More than Z\n"; } //cout << r << "\n"; char val = r; //cout< v(9,"........."); int pos=0; for(int i=3;i<=5;i++){ for(int j=3;j<=5;j++){ v[i][j]=st[pos]; if(st[pos] == '#'){ int k_col = j-4; int k_row =i-4; for(int z=1;z<3;z++){ v[i+z*k_row][j+z*k_col] = '#'; } } pos++; } } for(int i=0;i<9;i++){ for(int j=0;j<9;j++){ cout<>tests>>val; p["....*.##."] = 'A'; p["...#*..#."] = 'B'; p["#...*..#."] = 'C'; p[".#..*..#."] = 'D'; p["..#.*..#."] = 'E'; p["....*#.#."] = 'F'; p["....*..##"] = 'G'; p["...#*.#.."] = 'H'; p["#...*.#.."] = 'I'; p[".#..*#..."] = 'J'; p[".#..*.#.."] = 'K'; p["..#.*.#.."] = 'L'; p["....*##.."] = 'M'; p["....*.#.#"] = 'N'; p["#..#*...."] = 'O'; p[".#.#*...."] = 'P'; p["..##*...."] = 'Q'; p["...#*#..."] = 'R'; p["...#*...#"] = 'S'; p["##..*...."] = 'T'; p["#.#.*...."] = 'U'; p[".#..*...#"] = 'V'; p["..#.*#..."] = 'W'; p["..#.*...#"] = 'X'; p["#...*#..."] = 'Y'; p["....*#..#"] = 'Z'; while(tests--) { solve(val); } }