#include <iostream>
#include <cstdio>
#include <cassert>
#include <cstring>
#include <vector>
#include <valarray>
#include <array>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <complex>
#include <random>

using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr int TEN(int n) {return (n==0)?1:10*TEN(n-1);}

const int d4[4][2] = {
    {1, 0},
    {0, 1},
    {-1, 0},
    {0, -1},
};

bool solve() {
    bool g[8][8];
    for (int i = 0; i < 8; i++) {
        string s; cin >> s;
        for (int j = 0; j < 8; j++) {
            g[i][j] = (s[j] == '1');
        }
    }

    int x, y;
    cin >> x >> y; x--; y--;

    using P = pair<int, int>;
    queue<P> q;
    q.push(P(x, y));
    bool bk[8][8] = {};
    while (q.size()) {
        int x, y;
        tie(x, y) = q.front(); q.pop();
        if (bk[y][x] or !g[y][x]) continue;
        bk[y][x] = true;
        for (int d = 0; d < 4; d++) {
            int nx = x, ny = y;
            for (int i = 0; i < 3; i++) {
                nx += d4[d][0]; ny += d4[d][1];
                if (!(0 <= nx and nx < 8 and 0 <= ny and ny < 8)) continue;
                q.push(P(nx, ny));
            }
        }
    }
    for (int i = 0; i < 8; i++) {
        for (int j = 0; j < 8; j++) {
            if (!g[i][j] or bk[i][j]) {
                cout << '0';
            } else {
                cout << '1';
            }
        }
        cout << endl;
    }
    return true;
}

int main() {
    int ca = 0;
    cin >> ca;
    for (int i = 0; i < ca; i++) {
        cout << "Data " << i+1 << ":" << endl;
        if (!solve()) break;
    }
    return 0;
}