题目描述
Problem Description
JOI has invited his friends numbered from 1 to N to a Christmas party. As the party got lively, they decided to play the following game together:
- Initially, JOI selects one friend from the N friends as the target.
- JOI secretly informs the selected target that they are the target. Other friends do not know who the target is.
- Each friend, except the target, predicts who the target is and writes that person's name on a piece of paper. The target writes their own name on the paper.
- After everyone has written down their predictions, JOI announces the name of the target.
- Each person who guessed correctly earns 1 point. Since the target writes their own name, they always earn 1 point. Those who guessed incorrectly do not receive any points.
- Additionally, the target earns X extra points, where X is the number of people who guessed incorrectly.
JOI and his friends played this game M times. For each friend, calculate the total score from all M games.
Input Format
The input consists of 3 + M lines.
The first line contains the number of friends N (3 ≤ N ≤ 100).
The second line contains the number of games M (3 ≤ M ≤ 100).
The third line contains M integers A1, A2, ..., AM separated by spaces, indicating that the target in the i-th game (1 ≤ i ≤ M) is friend Ai (1 ≤ Ai ≤ N).
The following M lines, where the i-th line (1 ≤ i ≤ M) contains N integers Bi,1, Bi,2, ..., Bi,N separated by spaces, indicating that in the i-th game, friend j (1 ≤ j ≤ N) wrote down the name of friend Bi,j (1 ≤ Bi,j ≤ N). Since the target writes their own name, for j = Ai, it is always the case that Bi,j = j.
Output Format
Output the total score for each friend over the M games. The output consists of N lines. The j-th line (1 ≤ j ≤ N) should contain the total score of friend j.
Sample Input and Output
Sample Input #1
3
4
1 2 3 2
1 1 2
3 2 2
1 1 3
2 2 2
Sample Output #1
3
4
5
Sample Input #2
5
3
3 3 1
2 4 3 3 3
4 3 3 3 1
1 3 4 1 1
Sample Output #2
3
1
6
3
2
Notes/Hints
Sample Explanation 1
In the sample input #1, 3 friends play 4 games. - In the 1st game, the target is friend 1, who earns 2 points, friend 2 earns 1 point, and friend 3 earns 0 points. - In the 2nd game, the target is friend 2, who earns 2 points, friend 1 earns 0 points, and friend 3 earns 1 point. - In the 3rd game, the target is friend 3, who earns 3 points, friend 1 earns 0 points, and friend 2 earns 0 points. - In the 4th game, the target is friend 2, who earns 1 point, friend 1 earns 1 point, and friend 3 earns 1 point. After 4 games, the total scores are: friend 1 has 3 points, friend 2 has 4 points, and friend 3 has 5 points.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分