#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <complex>
#include <string>
#include <sstream>

#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>

using namespace std;

#define all(c) c.begin(),c.end()
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

typedef long long ll;
typedef vector<int> vi;

template<typename T>
ostream& operator<<(ostream& os,const vector<T>& val){
    os << "[ ";
    for(typename vector<T>::const_iterator it=val.begin();
        it != val.end();++it){
        os << *it << " ";
    }
    os << "]";
    return os;
}

const char bomb = '1';
const char emp = '0';
int N = 7;
void fire(int y,int x,vector<string> &f){
    if(f[y][x] == bomb){
        f[y][x] = emp;
        for(int i=-3;i<=3;i++){
            if(0 <= y + i and y + i <= N){
                fire(y+i,x,f);
            }
        }
        for(int i=-3;i<=3;i++){
            if(0 <= x + i and x + i <= N){
                fire(y,x+i,f);
            }
        }
    }
}
int main(){

    int n;
    cin >> n;
    for(int test=1;test<=n;test++){
        vector<string> field(8);
        rep(i,field.size()) cin >> field[i];
        int x,y;
        cin >> x >> y;
        x--;y--;
        fire(y,x,field);

        cout << "Data " << test << ":" << endl;
        for(int j=0;j<field.size();j++){
            cout << field[j] << endl;
        }
    }

    return 0;
}