Odd-even pairs

4

1 votes
Linear Algebra, Gaussian Elimination, Algorithms, Math
Problem

Although Nayra doesn't like stories of random arrays as a birthday present. But on her last birthday, she got one such array as a birthday present. After struggling for a day to figure out what to do with this array. She asked Aryan for help. He gave him this problem.

Formally, you are given an array A of N numbers. Let S be the set of XOR of all possible subsets of A.
Find count of distinct numbers in S which have an odd number of bits on. Similarly, find the count of distinct numbers in S which have an even number of bits on.
Since this count can be a very large report it modulo 998244353.

Subtasks

  1. 30 points: 0Ai<260
  2. 70 points: 0Ai<2250

Input format 

  • The first line contains (1T20) denoting the number of test cases.
  • The first line of each test case contains two integers (1N103) and (1M250).
  • Each of the next N lines of each test case contains a binary string of length M denoting A's elements.

Output format

  • For each test case print two integers in a single line,
  • The first integer should be the number of distinct numbers in S with an odd number of bits on modulo 998244353.
  • The second integer should be the number of distinct numbers in S with an even number of bits on modulo 998244353.

Constraints

1N1000

1T20

All elements of the array will be given in the binary form.

Note

A bitwise XOR (⊕ operator) takes two-bit integers of equal length and performs the logical xor operation on each pair of corresponding bits. The result in each position is 1 if only the first bit is 1 or only the second bit is 1 but will be 0 if both are 0 or both are 1. You can read more about bitwise XOR operation here.    

XOR of a subset B = {B_1, B_2, ...., B_k} is B_1 ⊕ B_2 ⊕ ... ⊕ B_k.

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

In the first testcase,
A = {0} and hence S = {0}.

In the second testcase,
A = {1} and hence S = {0,1}.
Here, 0 corresponds to an empty subset of A.     

In the third testcase,
A = {2,3,4,6,6,5} and hence S = {0,1,2,3,4,5,6,7}.
0,3,5,6 has an even number of bits on, whereas, 1,2,4,7 has an odd number of bits on.

Here, {2,3} has XOR 1 and {4,3,6,6} has XOR 7.

Editor Image

?