Problem:
Score : 400 points

Problem Statement

An SNS has N users - User 1, User 2, \cdots, User N.

Between these N users, there are some relationships - M friendships and K blockships.

For each i = 1, 2, \cdots, M, there is a bidirectional friendship between User A_i and User B_i.

For each i = 1, 2, \cdots, K, there is a bidirectional blockship between User C_i and User D_i.

We define User a to be a friend candidate for User b when all of the following four conditions are satisfied:

a \neq b.

There is not a friendship between User a and User b.

There is not a blockship between User a and User b.

There exists a sequence c_0, c_1, c_2, \cdots, c_L consisting of integers between 1 and N (inclusive) such that c_0 = a, c_L = b, and there is a friendship between User c_i and c_{i+1} for each i = 0, 1, \cdots, L - 1.

For each user i = 1, 2, ... N, how many friend candidates does it have?

Constraints

All values in input are integers.

2 ≤ N ≤ 10^5

0 \leq M \leq 10^5

0 \leq K \leq 10^5

1 \leq A_i, B_i \leq N

A_i \neq B_i

1 \leq C_i, D_i \leq N

C_i \neq D_i

(A_i, B_i) \neq (A_j, B_j) (i \neq j)

(A_i, B_i) \neq (B_j, A_j)

(C_i, D_i) \neq (C_j, D_j) (i \neq j)

(C_i, D_i) \neq (D_j, C_j)

(A_i, B_i) \neq (C_j, D_j)

(A_i, B_i) \neq (D_j, C_j)

Input

Input is given from Standard Input in the following format:

N M K
A_1 B_1
\vdots
A_M B_M
C_1 D_1
\vdots
C_K D_K

Output

Print the answers in order, with space in between.

Sample Input 1

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

Sample Output 1

0 1 0 1

There is a friendship between User 2 and 3, and between 3 and 4. Also, there is no friendship or blockship between User 2 and 4. Thus, User 4 is a friend candidate for User 2.

However, neither User 1 or 3 is a friend candidate for User 2, so User 2 has one friend candidate.

Sample Input 2

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

Sample Output 2

0 0 0 0 0

Everyone is a friend of everyone else and has no friend candidate.

Sample Input 3

10 9 3
10 1
6 7
8 2
2 5
8 4
7 3
10 9
6 4
5 8
2 6
7 5
3 1

Sample Output 3

1 3 5 4 3 3 3 3 1 0

Solution in Rust (1.42.0) (judge verdict: Accepted)

use std::io::*;
use std::str::FromStr;

//https://qiita.com/tubo28/items/e6076e9040da57368845
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

//https://onlinejudge.u-aizu.ac.jp/solutions/problem/ALDS1_5_B/review/2709881/arsenic28/Rust
trait Joinable {
    fn join(self, sep: &str) -> String;
}
impl<U: ToString, T: Iterator<Item = U>> Joinable for T {
    fn join(self, sep: &str) -> String {
        self.map(|x| x.to_string()).collect::<Vec<_>>().join(sep)
    }
}

// UnionFind
// coding: https://youtu.be/TdR816rqc3s?t=726
// comment: https://youtu.be/TdR816rqc3s?t=6822
#[derive(Debug)]
struct UnionFind {
    //ノード情報のベクトル。
    //各ノードは親のノードを指す。
    //根なら木のサイズを負にして入れる。
    d: Vec<isize>,
}

impl UnionFind {
    //コンストラクタ dをn個の要素でそれぞれサイズ-1で初期化
    fn new(n: usize) -> UnionFind {
        UnionFind { d: vec![-1; n] }
    }

    //ノード番号を引数にとり
    //属する木のグループ番号を返す
    //グループ番号は属する木の根のノード番号
    fn find(&mut self, x: isize) -> isize {
        let u_x = x as usize;
        //負値であれば、根である
        if self.d[u_x] < 0 {
            x
        } else {
            //再帰的に根を探索し、各ノードの根の番号を張り替える（経路縮約）
            self.d[u_x] = self.find(self.d[u_x]);
            self.d[u_x]
        }
    }

    //木の併合
    //木のサイズが小さい方を大きい方にくっつける
    //長いものにまかれにいく
    //木が深くならなくなる
    fn unite(&mut self, x: isize, y: isize) -> bool {
        //所属するグループの検索
        let mut x = self.find(x);
        let mut y = self.find(y);
        let mut u_x = x as usize;
        let mut u_y = y as usize;
        //すでに所属グループが同じ
        if x == y {
            return false;
        }
        //xを大きいサイズのグループに設定する
        if self.d[u_x] > self.d[u_y] {
            std::mem::swap(&mut x, &mut y);
            std::mem::swap(&mut u_x, &mut u_y);
        }
        //大きいグループxに小さいグループyのサイズを加算する
        self.d[u_x] += self.d[u_y];
        //グループyの親をxにするくっつける
        self.d[u_y] = x;
        return true;
    }

    //ノードxとノードyが同じグループか判定する
    fn same(&mut self, x: isize, y: isize) -> bool {
        self.find(x) == self.find(y)
    }
    //所属するグループのサイズを返す
    fn size(&mut self, x: isize) -> isize {
        let root = self.find(x);
        -self.d[root as usize]
    }
}

fn main() {
    let n: usize = read();
    let m: usize = read();
    let k: usize = read();
    let f: Vec<(isize, isize)> = (0..m)
        .map(|_| (read::<isize>() - 1, read::<isize>() - 1))
        .collect();
    let b: Vec<(isize, isize)> = (0..k)
        .map(|_| (read::<isize>() - 1, read::<isize>() - 1))
        .collect();
    let mut tree = UnionFind::new(n);

    //友達グループを作成
    for v in f.iter() {
        tree.unite(v.0, v.1);
    }

    let mut f_candidate: Vec<isize> = Vec::new();

    //各グループのサイズを所属する人ごとに
    //友達候補人数として格納
    //自分自身はカウントしないので、-1する
    for i in 0..n {
        f_candidate.push(tree.size(i as isize) - 1);
    }

    //すでに友達関係の分を候補数から引く
    for v in f.iter() {
        f_candidate[v.0 as usize] -= 1;
        f_candidate[v.1 as usize] -= 1;
    }

    //同じグループに所属していて、かつ、ブロック関係の場合、候補から除外
    for v in b.iter() {
        if tree.same(v.0, v.1) {
            f_candidate[v.0 as usize] -= 1;
            f_candidate[v.1 as usize] -= 1;
        }
    }

    println!("{}", f_candidate.iter().join(" "));
}