#120Medium
Rows similar to the first one
Time: 1 s · Memory: 256 MB
- Maps and sets
Statement
You are given an matrix with elements from to . Two rows are similar if they consist of the same set of numbers: repetitions and order do not matter, only which numbers occur. For example, 1 2 2 and 2 1 1 are similar (both are ).
Find the number of rows similar to the first one (the first row itself does not count).
Input format
The first line contains and (). The next lines contain integers each ().
Output format
A single integer — the number of similar rows.
Examples
Input
3 3 1 2 2 2 1 1 1 2 3
Output
1
Input
2 2 5 5 5 6
Output
0
Note
Turn every row into a set and compare it with the set of the first row. In the first example row 2 is similar, while row 3 has an extra — the answer is .
