def printboard( board )
	8.times{ |y|
		8.times{ |x|
			print board[ y ][ x ] 
		}
		puts
	}
end

def min( x , y)
	if x > y 
		y
	else
		x
	end
end
def max( x, y )
	if x > y
		x
	else
		y
	end
end

def bomb( board, sx, sy )
	chain = Array.new
	chain << [sx - 1,sy - 1]

	while chain.size > 0
		temp = chain.shift	
		tx = temp[ 0 ] 
		ty = temp[ 1 ]

		board[ ty ][ tx ] = 0

		lx1 = max( 0, tx - 3)
		lx2 = min( 7, tx + 3)
		lx1.upto( lx2 ){ |tempx|
			if board[ ty ][ tempx ] == 1
				chain << [tempx, ty ]
				board[ ty ][ tempx ] = 0
			end
		}

		ly1 = max( 0, ty - 3 )
		ly2 = min( 7, ty + 3 )
		ly1.upto( ly2 ){ |tempy|
			if board[ tempy ][ tx ] == 1
				chain << [tx, tempy ]
				board[ tempy ][ tx ] = 0
			end
		}
	end
	return board
end

def main

	answers = Array.new
	num = $stdin.gets.chomp.to_i

	num.times{|n|
		$stdin.gets #if n > 0

		board = Array.new( 8 ){ Array.new( 8 )}
		8.times{ |i|
			line = $stdin.gets
			temp = line.chomp.split(//).map{|n| n.to_i}
			8.times{ |j|
				board[ i ][ j ] = temp[ j ]
			}
		}
		x = $stdin.gets.chomp.to_i
		y = $stdin.gets.chomp.to_i
		b = bomb( board, x ,y )
		answers << b.dup
	}

	answers.each_with_index{ |b,i|
		print "Data #{i+1}:\n"
		printboard( b )
	}
	
end
main
