#include<iostream>
#include<string.h>
#include<vector>
#include<list>
#include<stdio.h>
#include<math.h>
#include<iomanip>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug " << x << endl;
using namespace std;

void output(char map[][14], int data){
    cout << "Data " << data << ":" << endl;
    range(i,3,11){
        range(j,3,11){
            cout << map[i][j];
        }cout << endl;
    }
}

void barn(char map[][14], int i, int j){
    map[i][j] = '0';
    range(k,1,4){
        if(map[i][j+k] == '1')
            barn(map, i, i+k);
        if(map[i][j-k] == '1')
            barn(map, i, j-k);
        if(map[i+k][j] == '1')
            barn(map, i+k, j);
        if(map[i-k][j] == '1')
            barn(map, i-k, j);
    }
}

int main(){
    int n;
    char map[14][14] = {'0'};
    cin >> n;
    rep(i,n){
        string s;
        rep(j,8){
            cin >> s;
            rep(k,8){
                map[j+3][k+3] = s[k];
            }
        }
        int x,y;
        cin >> x >> y;
        x+= 2; y+= 2;
        barn(map, y, x);
        output(map, i+1);
    }
}