#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>

using namespace std;

bool inside( int x, int y )
{
	return 0 <= x && x < 8 && 0 <= y && y < 8;
}

int main()
{
	int n;
	cin >> n;

	for ( int ni = 1; ni <= n; ni++ )
	{
		set< pair<int,int> > bomb;

		for ( int i = 0; i < 8; i++ )
		{
			string buffer;
			cin >> buffer;

			for ( int j = 0; j < 8; j++ )
			{
				if ( buffer[j] == '1' )
				{
					bomb.insert( make_pair( i, j ) );
				}
			}
		}

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

		queue< pair<int,int> > explosion;
		explosion.push( make_pair( y - 1, x - 1 ) );

		while ( !explosion.empty() )
		{
			pair<int,int> current;
			current = explosion.front();
			explosion.pop();

			for ( int i = -3; i <= 3; i++ )
			{
				if ( i != 0 )
				{
					pair<int,int> blast = current;
					blast.first += i;

					set< pair<int,int> >::iterator target = bomb.find( blast );
					if ( target != bomb.end() )
					{
						explosion.push( blast );
						bomb.erase( target );
					}
					
					blast = current;
					blast.second += i;

					target = bomb.find( blast );
					if ( target != bomb.end() )
					{
						explosion.push( blast );
						bomb.erase( target );
					}
				}
			}
		}

		cout << "Data " << ni << ':' << endl;
		for ( int i = 0; i < 8; i++ )
		{
			for ( int j = 0; j < 8; j++ )
			{
				if ( bomb.find( make_pair( i, j ) ) != bomb.end() )
				{
					cout << '1';
				}
				else
				{
					cout << '0';
				}
			}
			cout << endl;
		}
	}

	return 0;
}