#include <bits/stdc++.h>
#define LEN 8
using namespace std;
string table[LEN];

int fdx[] = {1, 0, -1, 0};
int fdy[] = {0, 1, 0, -1};

void dfs(int x, int y) {
    if((x < 0 || x >= LEN) || (y < 0 || y >= LEN)) return;
    if(table[y][x] == '1') {
        table[y][x] = '0';
        for(int r = 1; r <= 3; r++) {
            for(int c = 0; c < 4; c++) {
                dfs(x + fdx[c]*r, y + fdy[c]*r);
            }
        }
    }
    return;
}

//出力
void print() {
    for(int r = 0; r < LEN; r++) {
        cout << table[r] << endl;
    }
}

int main(void) {
    int no = 1;
    int n; cin >> n;
    for(int r = 0; r < n; r++) {
        putchar('\n');
        
        for(int r = 0; r < LEN; r++) {
            cin >> table[r];
        }
        int sx, sy; cin >> sx >> sy;
        dfs(sx-1, sy-1);
        cout<< "Data "<< no << ":" << endl;
        no++;
        print();
        for(int r = 0; r < LEN; r++) table[r].clear();
    }
}