Christmas Party
InterviewTime limit1sMemory limit256 MB
Tally each friend's score over M guessing games from the targets and the written names.
- Level
Easy1 of 10
- Topics
- Implementation
- Solved
- No attempts yet
Problem
JOI went to a Christmas party with friends, numbered friend 1 through friend . Once the party warmed up, JOI decided to play the following game with them.
- JOI picks one of the friends. Call that friend the target.
- JOI secretly tells only the chosen friend that they are the target. The other friends do not know who the target is.
- Each friend who is not the target writes on a slip of paper the name of the person they think is the target. The target writes their own name.
- Once everyone has written a name, JOI announces the target's name.
- A friend who wrote the target's name earns 1 point. The target wrote their own name, so the target always earns 1 point. A friend who wrote any other name earns nothing.
- If friends failed to write the target's name, the target earns additional points.
JOI and the friends played this game times. Compute each friend's total score after all games.
Input
The input has lines.
The first line contains the number of friends ().
The second line contains the number of games ().
The third line contains integers separated by spaces. () means that the target of game is friend .
The -th of the following lines contains integers separated by spaces. () means that in game , friend wrote the name of friend . The target writes their own name, so whenever it holds that .
Output
Print lines. Line contains the total score friend earned over the games.