#abc226b. [abc226_b]Counting Arrays
[abc226_b]Counting Arrays
Problem Statement
You are given sequences numbered to .
Sequence has a length of and its -th element is .
Sequence and Sequence are considered the same when and for every .
How many different sequences are there among Sequence through Sequence ?
Constraints
- The total number of elements in the sequences, , does not exceed .
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the number of different sequences.
Sample Input 1
4
2 1 2
2 1 1
2 2 1
2 1 2
Sample Output 1
3
Sample Input contains four sequences:
- Sequence :
- Sequence :
- Sequence :
- Sequence :
Except that Sequence and Sequence are the same, these sequences are pairwise different, so we have three different sequences.
Sample Input 2
5
1 1
1 1
1 2
2 1 1
3 1 1 1
Sample Output 2
4
Sample Input contains five sequences:
- Sequence :
- Sequence :
- Sequence :
- Sequence :
- Sequence :
Sample Input 3
1
1 1
Sample Output 3
1