P20537 [HackerEarth] Xenny and his friends came to know about a mobile phone product called NplusN, which could be bought if a person sent invitations to others to buy the phone.
普及
题目描述

Xenny and his friends came to know about a mobile phone product called NplusN, which could be bought if a person sent invitations to others to buy the phone.

They started sending and receiving several invitations of the highly coveted product.

There was however, a twist in the tale. The Association of CodeSprinters (ACS) announced that Xenny was the senior-most inviter among his friends, so the hierarchy would start from him. Every person was then assigned a hierarchy level (H), depending on how many intermediate people it took for an invitation to reach a person.

For example,

Consider the hierarchy:

Xenny -> Penny -> Sunny

in this case, the hierarchy level of Xenny is highest, hierarchy level of Penny is lower than Xenny but higher than Sunny, and hierarchy level of Sunny is the lowest among them all.

The ACS made some more rules:

For a certain person, only those invites will be considered which he made to people who were lower in the hierarchy as compared to him/her.

The total of a person's invites would be equal to the sum of invites sent by everyone who is just below him/her in the hierarchy.

People in the lowest level of hierarchy have 1 invite.

For example, in the above case, Sunny's number of invites would be 1, Jenny's invites would be 1 and Xenny's invites would be 1 as well.

Xenny's friend, Bhavesh, already had an awesome phone and wasn't interested in sending/receiving NplusN invites. So, he decided to perform some analytics on the entire scenario of invitations.

He had a list of every member's unique ID and a list of all exchanges of invitations, i.e., if a person A exchanged an invitation with person B, either A sent the invitation to B, or B sent the invitation to A - both cases were possible.

Help Bhavesh in finding out the total number of invites sent by each person.

Input Format

First lines contains 2 space-separated positive integers - N and M - denoting the number of people and the number of exchanges respectively.

M lines follow. Each line contains 2 space-separated integers X and Y - denoting an exchange of invitation between people with unique IDs X and Y.

Last line of input contains a single integer S - denoting the unique ID of Xenny.

Output Format

Output N space-separated integers, each denoting the number of invites of the i^th person.

Constraints

1 ≤ N ≤ 10^5

1 ≤ M ≤ 5 * 10^5

1 ≤ X, Y, S ≤ N

SAMPLE INPUT
6 7
1 2
1 3
1 5
3 4
4 5
4 6
5 6
1

SAMPLE OUTPUT
3 0 1 1 2 1

输入格式

见题面

输出格式

见题面

样例输入
2 1 2 1 1
样例输出
1 1 1 1 1 6 1 7 5 1 6 5 1 6 7 4 8 72 1 1 4