#include <bits/stdc++.h>

using namespace std;

struct Point {
    int x, y;
};

int main() {

    int n, sx, sy;
    char line, graph[8][9];
    int vx[] = {0, 1, 0, -1};
    int vy[] = {-1, 0, 1, 0};

    cin >> n;

    for(int i = 1; i <= n; ++i) {

        // cin >> line;

        for(int j = 0; j < 8; ++j) {
            cin >> graph[j];
        }

        cin >> sx >> sy;

        queue<Point> q;
        q.push((Point){sx - 1, sy - 1});

        while(!q.empty()) {

            Point now = q.front(); q.pop();

            graph[now.y][now.x] = '0';

            for(int j = 0; j < 4; ++j) {
                for(int k = 1; k <= 3; ++k) {

                    Point next = now;
                    next.x = now.x + vx[j] * k;
                    next.y = now.y + vy[j] * k;

                    if(next.x >= 0 && next.x < 8 && next.y >= 0 && next.y < 8 && graph[next.y][next.x] == '1') {
                        q.push(next);
                    }

                }
            }

        }

        cout << "Data " << i << ":" << endl;

        for(int j = 0; j < 8; ++j) {
            cout << graph[j];
            cout << endl;
        }

    }

}