[Ipsc2008]Discover All Sets

时间限制:100s      空间限制:357MB

题目描述


输入格式

The first line of the input file contains an integer T specifying the number of test cases. Each test case is preceded by a blank line. Each test case looks as follows: The first line contains three positive integer N, M and K giving the number of different properties of the cards, the number of different values of a single property, and the number of cards drawn. Each of the next K lines describes one of these cards. The i-th of these lines (1 ≤ i ≤ K) contains exactly N numbers pi,j (1 ≤ j ≤ N), 1 ≤ pi,j ≤ M. Value pi,j is the value of the j-th property of the i-the card.


输出格式


样例输入

1
4 3 12
1 1 1 2
2 3 3 3
2 2 3 1
1 3 1 3
3 3 3 3
1 2 1 1
2 1 3 2
1 1 3 2
2 3 2 3
1 3 2 3
3 2 1 1
3 1 2 2

样例输出

11

提示


题目来源

没有写明来源

Menuappsclose