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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;

int a[14][14];

int bomb(int y, int x)
{
    a[y][x] = 0;
    for (int i = 1; i <= 3; i++)
    {
       
        if (a[y + i][x] == 1)
            bomb(y + i, x);
        if (a[y - i][x] == 1)
            bomb(y - i, x);
        if (a[y][x + i] == 1)
            bomb(y, x + i);
        if (a[y][x - i] == 1)
            bomb(y, x - i);
    }

    return 0;
}

int main()
{
    rep(i, 14) rep(j, 14) a[i][j] = 0;
    int n;
    cin >> n;

    rep(k, n)
    {
        for (int i = 3; i <= 10; i++)
        {
            string s;
            cin >> s;
            for (int j = 3; j <= 10; j++)
            {
                a[i][j] = s[j - 3] - '0';
            }
        }
        int x, y;
        cin >> y >> x;

        bomb(x + 2, y + 2);

        printf("Data %d:\n", k + 1);
        for (int i = 3; i <= 10; i++)
        {
            for (int j = 3; j <= 10; j++)
            {
                cout << a[i][j];
            }
            cout << endl;
        }
    }

    return 0;
}
