#include <stdio.h>

typedef struct bomb {
        int x;
        int y;
} bomb;

int main() {
        const int N = 10;
        int mass[N][N];
        bomb b[64];
        int cnt = 0, top = 0, end = 0;
        char s[9];
        for (int i = 0; i < N; i++) {
                for (int j = 0; j < N; j++) {
                        mass[i][j] = -1;
                }
        }

        int num;
        scanf("%d", &num);
        for (int n = 0; n < num; n++) {
                for (int i = 0; i < 8; i++) {
                        scanf("%s", s);
                        for (int j = 0; j < 8; j++) {
                                mass[i+1][j+1] = s[j] == '1' ? 1 : 0;
                        }
                }
                scanf("%d", &b[end].x);
                scanf("%d", &b[end].y);
                cnt++;
                end++;
                while (cnt) {
                        int x = b[top].x, y = b[top].y;
                        mass[y][x] = 0;
                        for (int dx = -3; dx <= 3; dx++) {
                                if (mass[x+dx][y] == -1) {
                                        continue;
                                }
                                if (mass[y][x+dx] == 1) {
                                        b[end].x = x+dx;
                                        b[end].y = y;
                                        cnt++;
                                        end++;
                                }
                        }
                        for (int dy = -3; dy <= 3; dy++) {
                                if (mass[y+dy][x] == -1) {
                                        continue;
                                }
                                if (mass[y+dy][x] == 1) {
                                        b[end].x = x;
                                        b[end].y = y+dy;
                                        cnt++;
                                        end++;
                                }
                        }
                        cnt--;
                        top++;
                }

                printf("Data %d:\n", n+1);
                for (int i = 0; i < 8; i++) {
                        for(int j = 0; j < 8; j++) {
                                printf("%d", mass[i+1][j+1]);
                        }
                        printf("\n");
                }
        }

        return 0;
}