#include <iostream>
using namespace std;
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
void bakuhatu(char chart[][10][12],int m1,int x,int y)
{
   int i,j,k,l;
   int start,end;
   int range = 3;

   chart[m1][x][y] = 0;

   if(x- range < 1) start = 0;
   else start = x - range;
   
   if(x+ range > 7) end = 8;
   else end = x + range;

   for(i=start; i<end; i++) {
      if(chart[m1][i][y]) bakuhatu(chart,m1,i,y);
   }


   if(y - range < 1) start = 0;
   else start = y - range;
   
   if(y + range > 7) end = 8;
   else end = y + range;

   for(i=start; i<end; i++) {
      if(chart[m1][x][i]) bakuhatu(chart,m1,i,y);
   }
}
int main(void)
{
   int i,j,k,l;
   int a,b,c,d;
   int memory[2];
   int x,y;
   int n;
   char chart[1000][10][12] = {};
   char iranai[3];

   scanf("%d",&n);
   for(i=0;i<n;i++) {
      for(j=0;j<10;j++) scanf("%s",chart[i][j]);
      scanf("%d",&x);
      scanf("%d",&y);
      bakuhatu(chart,i,x-1,y-1);
   }
   for(i=0;i<n;i++) {
      printf("Data %d:\n",i+1);
      for(j=0;j<8;j++) printf("%s\n",chart[i][j]);
   }
   return 0;
}