QuizMania

0

0 votes
Medium
Problem

Kornala lives in the city of Quizland. He can always be found doing quizzes no matter where he is. He occasionally dreams about quizzes. Once a while in his dream he saw a library and went inside. The librarian was aware of Koru's interest in quizzes so she decided to put up a challenge infront of him. 

There were M rooms in the libarary consisting of quiz books out of which some of the rooms were locked. She gave Koru N remote controls. Each remote control was attached to some of the Rooms. Pressing a remote control button toggles some of the locks of the rooms. Now Koru wants to visit maximum number of rooms.

Help Koru find the maximum number of rooms that he can unlock using some ( including all or none ) of the sets of the remote controls and the number of ways to achieve this.

Input:

First line of Input contains T denoting the number of test cases.

First line of each test case contains two space separated integers N and M denoting the number of remote controls and number of rooms respectively.

Second line of each test case contains a string S denoting the initial state of the M rooms. If the value of the string at the 'ith' position if 0 then it denotes that the room 'i' is locked. If it is 1, the room is unlocked. 

N lines follow each containing M numbers (either 0 or 1 ) denoting the function of the remote control for each of the M rooms. If the value at the 'ith' line and 'jth' position is 1, it denotes that the remote control numbered 'i' will toggle the state of the room numbered 'j'.

Output:

For each test case, print two space separated integers. First number denotes the maximum number of rooms that can be unlocked by choosing a set of remote controls and applying it on the initlal state of the rooms. Second number denotes the total number of ways to get maximum number of rooms unlocked. 

Print the answer to each test case in separate line.

Constraints:

1<=T<=10

1<=N<=50

1<=M<=50

length of S = M

length of R[i] = M for  i=1 to N

Problem Setter:

Shikhar Kunal

Sample Input
3
3 4
1011
0000
0000
0000
5 5
10000
11000
01100
00110
00011
10001
4 2
00
00
00
00
00
Sample Output
3 8
5 2
0 16
Time Limit: 4
Memory Limit: 256
Source Limit:
Editor Image

?