atcoder#ABC226B. [ABC226B] Counting Arrays
[ABC226B] Counting Arrays
Score : points
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.
4
2 1 2
2 1 1
2 2 1
2 1 2
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.
5
1 1
1 1
1 2
2 1 1
3 1 1 1
4
Sample Input contains five sequences:
- Sequence :
- Sequence :
- Sequence :
- Sequence :
- Sequence :
1
1 1
1