Tracking Fake News

Model a story spreading through a social network where each person reposts only if a weighted sum of the story's categories equals their target.

Easy3GraphBFSSimulationNo attempts yetTime limit2sMemory limit512 MB

Problem

Fake news often travels through a social network. Someone posts a story that matches what a reader already believes, the reader accepts it with far less scrutiny than a story they disagree with, and the reader posts it too. The reader's friends see it next, and a story that panders hard enough can burn through a whole network. In this problem you simulate that spread. You are given the social network, the preferences of every individual, and the place where the story starts.

The model is simple, if a little unrealistic. There are rr categories that matter to a reader, such as which political side the story flatters, how much sex it contains, or how much violence it contains. Individual jj has an integer weight wj,iw_{j,i} for category ii, which may be positive or negative, and an integer target tjt_j for total content. A story has an integer content cic_i for each category. Individual jj likes a story exactly when i=1rwj,ici=tj\sum_{i=1}^{r} w_{j,i} c_i = t_j. The requirement is strict, but it is easy to compute. An individual who likes the story reposts it, and one who does not stays quiet. Everyone sees every story posted by a friend, and no story posted by anyone else unless a friend reposts it.

The story always starts at individual 1, who may still refuse to post it.

Input

The first line contains K1K \ge 1, the number of data sets in the input. KK data sets follow, each in the form below.

The first line of a data set contains two integers nn and rr, where 1n10001 \le n \le 1000 is the number of individuals in the social network and 1r1001 \le r \le 100 is the number of categories that matter for stories.

The next line contains exactly rr integers c1c_1 through crc_r, each between 100-100 and 100100 inclusive.

Then come nn lines, one for each individual jj in order from 1 to nn. The first rr numbers on a line are wj,1w_{j,1} through wj,rw_{j,r}, integers between 10-10 and 1010 inclusive. Next comes tjt_j, an integer between 1000000-1000000 and 10000001000000 inclusive. Next comes djd_j with 0djn10 \le d_j \le n - 1, the number of friends of jj. After that come djd_j distinct integers between 1 and nn, none of them equal to jj, which are the friends of jj. Friendship is always mutual: if jj' is a friend of jj, then jj is a friend of jj' as well.

The fake news story always starts at individual 1.

Output

For each data set, print "Data Set x:" on a line by itself, where x is the number of the data set counting from 1. On the next line print the total number of people who have posted the fake news story once no one new posts. Print a blank line after each data set.