B - Personnel Change 解説 /

実行時間制限: 2 sec / メモリ制限: 1024 MiB

配点 : 200

問題文

高橋君の勤めている会社には N 人の社員がおり、各社員には 1,2,\dots,N の社員番号が割り当てられています。 社内には M 個の部門があり、部門 1,2,\dots,M と呼ばれています。

社員番号 i の社員は、今期は部門 A_i に所属しており、来期は部門 B_i に所属します。

部門 1,2,\dots,M それぞれに対して、来期の所属人数から今期の所属人数を引いた値を求めてください。

制約

  • 1 \leq N \leq 100
  • 1 \leq M \leq 100
  • 1 \leq A_i \leq M
  • 1 \leq B_i \leq M
  • 入力はすべて整数

入力

入力は以下の形式で標準入力から与えられる。

N M
A_1 B_1
A_2 B_2
\vdots
A_N B_N

出力

M 行出力せよ。j 行目には部門 j についての答えを出力せよ。


入力例 1

5 4
1 2
2 1
3 1
2 2
2 4

出力例 1

1
-1
-1
1
  • 部門 1 について、今期は社員番号 11 人が所属し、来期は社員番号 2,32 人が所属します。
  • 部門 2 について、今期は社員番号 2,4,53 人が所属し、来期は社員番号 1,42 人が所属します。
  • 部門 3 について、今期は社員番号 31 人が所属し、来期は誰も所属しません。
  • 部門 4 について、今期は誰も所属せず、来期は社員番号 51 人が所属します。

入力例 2

10 5
3 2
3 4
1 2
2 2
4 4
3 1
3 4
4 2
3 3
3 2

出力例 2

0
4
-5
1
0

Score : 200 points

Problem Statement

The company where Takahashi works has N employees, each assigned an employee number from 1, 2, \dots, N. There are M departments in the company, called departments 1, 2, \dots, M.

Employee i belongs to department A_i this term and will belong to department B_i next term.

For each of departments 1, 2, \dots, M, find the number of members next term minus the number of members this term.

Constraints

  • 1 \leq N \leq 100
  • 1 \leq M \leq 100
  • 1 \leq A_i \leq M
  • 1 \leq B_i \leq M
  • All input values are integers.

Input

The input is given from Standard Input in the following format:

N M
A_1 B_1
A_2 B_2
\vdots
A_N B_N

Output

Output M lines. The j-th line should contain the answer for department j.


Sample Input 1

5 4
1 2
2 1
3 1
2 2
2 4

Sample Output 1

1
-1
-1
1
  • For department 1: this term, one employee (employee number 1) belongs; next term, two employees (employee numbers 2, 3) belong.
  • For department 2: this term, three employees (employee numbers 2, 4, 5) belong; next term, two employees (employee numbers 1, 4) belong.
  • For department 3: this term, one employee (employee number 3) belongs; next term, no one belongs.
  • For department 4: this term, no one belongs; next term, one employee (employee number 5) belongs.

Sample Input 2

10 5
3 2
3 4
1 2
2 2
4 4
3 1
3 4
4 2
3 3
3 2

Sample Output 2

0
4
-5
1
0