Problem2272--Counting Arrays

2272: Counting Arrays

[Creator : ]
Time Limit : 1.000 sec  Memory Limit : 128 MB

Description

给定N个序列,编号为1到N

第i个序列的长度是Li,第i个序列的第j个元素是aij。

请你确定有多少个互不相同的序列,请输出答案。



You are given NN sequences numbered 11 to NN.

Sequence ii has a length of L_iLi and its jj-th element (1 \leq j \leq L_i)(1≤j≤Li) is a_{i,j}ai,j.
Sequence ii and Sequence jj are considered the same when L_i = L_jLi=Lj and a_{i,k} = a_{j,k}ai,k=aj,k for every kk (1 \leq k \leq L_i)(1≤k≤Li).
How many different sequences are there among Sequence 11 through Sequence NN?

Constraints

  • 1 \leq N \leq 2 \times 10^51≤N≤2×105
  • 1 \leq L_i \leq 2 \times 10^51≤Li≤2×105 (1 \leq i \leq N)(1≤i≤N)
  • 0 \leq a_{i,j} \leq 10^{9}0≤ai,j≤109 (1 \leq i \leq N, 1 \leq j \leq L_i)(1≤i≤N,1≤j≤Li)
  • The total number of elements in the sequences, \sum_{i=1}^N L_i∑i=1NLi, does not exceed 2 \times 10^52×105.
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:
NNL_1L1a_{1,1}a1,1a_{1,2}a1,2\dots…a_{1,L_1}a1,L1L_2L2a_{2,1}a2,1a_{2,2}a2,2\dots…a_{2,L_2}a2,L2\vdots⋮L_NLNa_{N,1}aN,1a_{N,2}aN,2\dots…a_{N,L_N}aN,LN

Output

Print the number of different sequences.

Sample Input Copy

4
2 1 2
2 1 1
2 2 1
2 1 2

Sample Output Copy

3

HINT

Sample Input 11 contains four sequences:

  • Sequence 11 : (1, 2)(1,2)
  • Sequence 22 : (1, 1)(1,1)
  • Sequence 33 : (2, 1)(2,1)
  • Sequence 44 : (1, 2)(1,2)

Except that Sequence 11 and Sequence 44 are the same, these sequences are pairwise different, so we have three different sequences.

Source/Category