PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#DSU0000054. Gợi ý kết bạn (Friend Suggestions)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Gợi ý kết bạn (Friend Suggestions)

Friend Suggestions

Source: AtCoder

Version: Phuoc Hung OJ Extended

Problem Statement

A social network contains nn users numbered from 11 to nn. There are mm friendship pairs and kk blocking pairs. Both relations are undirected. Pairs do not repeat, and a pair cannot be both friends and blocked.

Two users belong to the same friendship network if a chain of friendships connects them, even if they have not directly befriended each other. For user ii, user jj is a potential friend suggestion if i≠ji\ne j, they belong to the same friendship network, are not already direct friends, and have not blocked each other.

Determine the number of potential friend suggestions for every user. Counting suggestions does not change any friendship or blocking relation.

Input

Read n,m,kn,m,k; then mm friendship pairs and kk block pairs. All pairs join distinct users, are unique within their categories, and no pair belongs to both categories.

Output

Print the candidate counts for the nn users.

Subtasks

  • Subtask 1 (20 points): 2≤n≤252\le n\le25, 0≤m,k≤3000\le m,k\le300; 1≤Ai,Bi,Ci,Di≤n1\le A_i,B_i,C_i,D_i\le n; there are no self-pairs, repeated pairs, or pairs belonging to both relation types.
  • Subtask 2 (30 points): 2≤n≤20002\le n\le2000, 0≤m,k≤1050\le m,k\le10^5; 1≤Ai,Bi,Ci,Di≤n1\le A_i,B_i,C_i,D_i\le n; there are no self-pairs, repeated pairs, or pairs belonging to both relation types.
  • Subtask 3 (50 points): 2≤n≤1052\le n\le10^5, 0≤m,k≤1050\le m,k\le10^5; 1≤Ai,Bi,Ci,Di≤n1\le A_i,B_i,C_i,D_i\le n; there are no self-pairs, repeated pairs, or pairs belonging to both relation types.

Examples

Input

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

Output

0 1 0 1

Explanation

All four people belong to one friendship component. User 11 is already friends with 2,32,3 and has blocked 44, leaving no candidate. User 22 can befriend 44. User 33 is already friends with everyone else. User 44 can befriend 22 but has blocked 11. The result is 0 1 0 1.