Christmas Party

No attempts yetTime limit1sMemory limit256 MB

Problem

JOI went to a Christmas party with NN friends, numbered friend 1 through friend NN. Once the party warmed up, JOI decided to play the following game with them.

  1. JOI picks one of the NN friends. Call that friend the target.
  2. JOI secretly tells only the chosen friend that they are the target. The other friends do not know who the target is.
  3. 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.
  4. Once everyone has written a name, JOI announces the target's name.
  5. 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.
  6. If XX friends failed to write the target's name, the target earns XX additional points.

JOI and the friends played this game MM times. Compute each friend's total score after all MM games.

Input

The input has 3+M3 + M lines.

The first line contains the number of friends NN (3N1003 \le N \le 100).

The second line contains the number of games MM (3M1003 \le M \le 100).

The third line contains MM integers A1,A2,,AMA_1, A_2, \dots, A_M separated by spaces. AiA_i (1AiN1 \le A_i \le N) means that the target of game ii is friend AiA_i.

The ii-th of the following MM lines contains NN integers Bi,1,Bi,2,,Bi,NB_{i,1}, B_{i,2}, \dots, B_{i,N} separated by spaces. Bi,jB_{i,j} (1Bi,jN1 \le B_{i,j} \le N) means that in game ii, friend jj wrote the name of friend Bi,jB_{i,j}. The target writes their own name, so whenever j=Aij = A_i it holds that Bi,j=jB_{i,j} = j.

Output

Print NN lines. Line jj contains the total score friend jj earned over the MM games.