400545: GYM100203 D Different vectors
Description
You are given a set of N vectors, each vector consists of K integers. Vector X is equivalent to Y (denoted X ≡ Y) iff there exist a bijection and an integer r, such that for each i in the range [0..K - 1].
For example, (1, 2, 2, 3) ≡ (22, 3, 4, 22), with r = 2 and f(22) = 2, f(3) = 3 and f(4) = 1. But (22, 3, 22, 4) is not equivalent to (1, 2, 2, 3).
How many pairwise nonequivalent vectors are there in a given set of N vectors?
InputFirst number contains T (T ≤ 10), number of test cases. Each test case consists of the following. First line consists of N and K (1 ≤ N ≤ 10000, 1 ≤ K ≤ 100). N lines follow, the i-th containing K integers describing the i-th vector. The vector values are from the range [0, 109].
OutputOutput one number: the number of different vectors.
ExamplesInput2Output
3 4
22 3 4 22
1 2 2 3
22 3 22 4
5 5
3 3 3 0 3
8 4 4 4 0
1 1 1 1 1
1 1 8 6 1
1 3 3 3 5
2
3