The annual Children’s Day is coming.Teacher Chen with other teachers is considering rewarding the acmer of swust.Then what is the present?Surely,it is the lollipop!Assuming there are N boys,M girls.The ith boy will get Ai candies,the ith girl will get Bi candies if there is no restriction.But there keeps intimate relationship between some boys and some girls (You know it!),so they won’t be get candies simultaneously.the following example will explain it:
Assuming there is a boy B and a girl G,if there is no restriction,Boy B will get x candies,Girl G will get y candies.But based on the intimate relationship between them , they can’s get candies simultaneously,so the most candies they get are Max(x,y).
Now,Here comes the problem:choose some girls and boys to get the most candies for them,what’s more,it must guarantee that none any so-called intimate relationship exists among them.
You,as a talented programmer,must have the ability to find the most candy numbers they get.Right?
The first line of input contains a number T, representing the numbers of test cases.Then each test case contains three parts:
The first part: N and M(1<=N,M<=200),representing the numbers of boys and girls respectively.
The second part: N numbers,representing the candy numbers, Ai(0<Ai<=100) for the ith boy under nonrestraint condition from left to right(1<=i<=N).
The third part: M numbers,representing the candy numbers, Bi (0<Bi<=100) for the ith girl under nonrestraint condition from left to right(1<=i<=M).
The last part: one 0-1 matrix with its size N by M.Considering the ith row,the jth column element of it.if 1,representing that the ith boy and the jth girl keep intimate relationship,so they can’s get candies simultaneously.otherwise 0,representing they can get candies simultaneously.