400545: GYM100203 D Different vectors

Memory Limit:64 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

D. Different vectorstime limit per test1 secondmemory limit per test64 megabytesinputstandard inputoutputstandard output

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?

Input

First 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].

Output

Output one number: the number of different vectors.

ExamplesInput
2
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
Output
2
3

加入题单

算法标签: