P23706 [AtCoder] [ABC016C] Friends of Friends
普及
题目描述

Problem Description

Takahashi is the administrator of a social networking service (SNS). In this SNS, users can connect with each other as friends. Takahashi decided to investigate how many "friends of friends" each user has. Given the friendship relationships, calculate the number of "friends of friends" for each user. Note that oneself and direct friends are not included in the "friends of friends".

Input Format

The input is given from the standard input in the following format:

$ N $ $ M $ $ A_1 $ $ B_1 $ $ A_2 $ $ B_2 $ : $ A_M $ $ B_M $

  • The first line contains the number of users $N\ (1≦N≦10)$ and the number of friendship pairs $M\ (0≦M≦N×(N-1)/2)$, separated by spaces.
  • Each user is assigned a user ID from $ 1 $ to $ N $.
  • The next $ M $ lines contain the user IDs $A_i,B_i\ (1≦A_i\$ i≠j $, then $ (A_i,B_i)≠(A_j,B_j) $.

Output Format

Output the number of friends of friends for each user in the order of their user IDs, one per line. Ensure a newline at the end of the output.

Sample Input and Output

Sample Input #1

3 2
1 2
2 3

Sample Output #1

1
0
1

Sample Input #2

3 3
1 2
1 3
2 3

Sample Output #2

0
0
0

Sample Input #3

8 12
1 6
1 7
1 8
2 5
2 6
3 5
3 6
4 5
4 8
5 6
5 7
7 8

Sample Output #3

4
4
4
5
2
3
4
2

Notes/Hints

None

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
3 2 1 2 2 3
样例输出
1 0 1