#include<iostream>
using namespace std;

void explode( int x, int y, char b[14][14] )       //2次元配列の渡し方に注意
{
    //x列目のy行目と渡される
    b[y][x] = '0';
    for( int i = -3; i <= 3; i++ )
    {   
        //縦方向の爆発
        if( b[y][x+i] == '1' )                     //爆発
            explode( x + i, y, b );
        else                                       //爆発しない
            b[y][x+i] = '0';

        //横方向の爆発
        if( b[y+i][x] == '1' )
            explode( x, y + i, b );
        else
            b[y+i][x] = '0';
    }
    return;
}

void initialize( char b[14][14] )
{
    for( int i = 0; i < 14; i++ )
        for( int j = 0; j < 14; j++ )
            b[i][j] = '0';
}

int main()
{
    char b[14][14];
    int n, x, y;

    cin >> n;

    for( int k = 1; k <= n; k++ )
    {
        initialize( b );

        //入力
        for( int i = 3; i <= 10; i++ )
            for( int j = 3; j <= 10; j++ )
                cin >> b[i][j];

        cin >> x >> y;

        cout << "Data " << k << ":" << endl;    //忘れた

        //爆破
        explode( x + 2, y + 2, b );             //x+2列目の、y+2行目と見る
        
        //出力
        for( int i = 3; i <= 10; i++ )
        {
            for( int j = 3; j <= 10; j++ )
                cout << b[i][j];
            cout << endl;
        }
    }
    return 0;
}
