#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define MAX_N 8

vector<string> m(8);
bool visited[MAX_N][MAX_N];
int x, y;
int dx[] = {1,0,-1,0}, dy[] = {0,1,0,-1};

void dfs(int x, int y) {
    m[y][x] = '0';
    visited[y][x] = true;

    rep(i,4) {
        for(int n=1; n<=3; n++) {
            int nx = x + n * dx[i];
            int ny = y + n * dy[i];
            if(visited[ny][nx]) continue;
            if(0<=nx and nx<8 and 0<=ny and ny<8 and m[ny][nx]=='1')
                dfs(nx, ny);
        }
    }
}

int main() {
    int n; cin >> n;
    rep(data,n) {
        rep(i,8) cin>>m[i];
        memset(visited, 0, sizeof(visited));
        cin >> x >> y; x--; y--;
        dfs(x, y);

        printf("Data %d:\n", data+1);
        rep(i,8) cout << m[i] << "\n";
    }

    
    return 0;
}