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 C# (Mono 4.6.2.0) (judge verdict: Accepted)

using System;
using System.Linq;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using static program.Input;
using static program.MyMath;
using static System.Console;
using static program.Const;

namespace program
{
    static class Const
    {
        public static string alp = "abcdefghijklmnopqrstuvwxyz";
        public static string Alp = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        public const long MOD = 1000000007;
        public static int INF = int.MaxValue;
        public static long INFL = long.MaxValue;
    }
    class Program
    {
        static void Main()
        {
            var input = ScanIntArray();
            var n = input[0]; var m = input[1]; var k = input[2];
            var fr = new int[n];
            var bl = new int[n].Select(_=> new List<int>()).ToArray();
            var uf = new UnionFind(n);
            for(int i=0; i<m; i++)
            {
                input = ScanIntArray();
                uf.unite(input[0]-1, input[1]-1);
                fr[input[0]-1]++;
                fr[input[1]-1]++;
            }
            for (int i = 0; i < k; i++)
            {
                input = ScanIntArray();
                bl[input[0]-1].Add(input[1]-1);
                bl[input[1]-1].Add(input[0]-1);
            }
            int[] fr2 = new int[n];
            for(int i=0; i<n; i++)
            {
              var res = uf.size[uf.root(i)] - fr[i] - 1;
              foreach(var b in bl[i])
                if(uf.same(i, b)) res --;
              fr2[i] = res;
            }
          WriteLine(fr2.Join(" "));
        }
        class UnionFind
        {
            public int[] parent;
            public int[] size;
            public UnionFind(int n)
            {
                parent = new int[n];
                size = Enumerable.Repeat(1, n).ToArray();
                for (int i = 0; i < n; i++) parent[i] = i;
            }
            public int root(int x)
            {
                while (parent[x] != x) { x = parent[x] = parent[parent[x]]; }
                return x;
            }

            public void unite(int x, int y)
            { 
                int rx = root(x);
                int ry = root(y); 
                if (rx == ry) return;
                size[ry] += size[rx];
                parent[rx] = ry;
            }

            public bool same(int x, int y)
            { 
                int rx = root(x);
                int ry = root(y);
                return rx == ry;
            }
        }
    }

    static class Input
    {
        static public int ScanInt() { return int.Parse(Console.ReadLine()); }
        static public uint ScanUint() { return uint.Parse(Console.ReadLine()); }
        static public double ScanDouble() { return double.Parse(Console.ReadLine()); }
        static public long ScanLong() { return long.Parse(Console.ReadLine()); }
        static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); }
        static public int[] ScanIntArray() { return Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray(); }
        static public uint[] ScanUintArray() { return Console.ReadLine().Split().Select(x => uint.Parse(x)).ToArray(); }
        static public double[] ScanDoubleArray() { return Console.ReadLine().Split().Select(x => double.Parse(x)).ToArray(); }
        static public long[] ScanLongArray() { return Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray(); }
        static public ulong[] ScanUlongArray() { return Console.ReadLine().Split().Select(x => ulong.Parse(x)).ToArray(); }

        static public string ScanStr() { return Console.ReadLine(); }
        static public string[] ScanStrArray() { return ScanStr().Split(); }
        static public string RegaxReplace(this string arg1, string pattern, string replacement) { return Regex.Replace(arg1, pattern, replacement); }
        static public string Join<T>(this IEnumerable<T> source, string separator) { return string.Join(separator, source); }
        static public void Sort(this string[] array) { Array.Sort(array, StringComparer.OrdinalIgnoreCase); }
        static public void StringSort(this List<string> list) { list.Sort(StringComparer.OrdinalIgnoreCase); }
    }

    static class MyMath
    {
        static public int Floor2(this int a)
        {
            int N = 1;
            while (N < a) N *= 2;
            return N / 2;
        }
        static public long Floor2(this long a)
        {
            long N = 1;
            while (N < a) N *= 2;
            return N / 2;
        }
        static public int Ceiling2(this int a)
        {
            int N = 1;
            while (N < a) N *= 2;
            return N;
        }
        static public long Ceiling2(this long a)
        {
            long N = 1;
            while (N < a) N *= 2;
            return N;
        }
        static public long[] CumSum(this long[] a)
        {
            var res = new long[a.Length];
            long s = 0;
            for (int i = 0; i < a.Length; i++) res[i] = (s += a[i]);
            return res;
        }
        static public IEnumerable<int> PrimeFactors(this int n)
        {
            int tmp = n;
            for (int i = 2; i * i <= n; i++)
            {
                while (tmp % i == 0)
                {
                    tmp /= i;
                    yield return i;
                }
            }
            if (tmp != 1) yield return tmp;
        }
        static public IEnumerable<long> PrimeFactors(this long n)
        {
            var tmp = n;
            for (long i = 2; i * i <= n; i++)
            {
                while (tmp % i == 0)
                {
                    tmp /= i;
                    yield return i;
                }
            }
            if (tmp != 1) yield return tmp;
        }
        static public int Digit(this int n, int d) { if (d < 0) return 0; return (n % (int)Math.Pow(10, d + 1)) / (int)Math.Pow(10, d); }
        static public int Length(this int n) { if (n < 0) return 0; return (int)Math.Log10(n) + 1; }
        static public int Top(this int n) { return n.Digit(n.Length() - 1); }
        public static bool isPrime(this int p)
        {
            if (p <= 1) return false;
            for (int i = 2; i * i <= p; i++)
                if (p % i == 0) return false;
            return true;
        }
        public static bool isPrime(this long p)
        {
            if (p <= 1) return false;
            for (long i = 2; i * i <= p; i++)
                if (p % i == 0) return false;
            return true;
        }
        public static int GCD(int a, int b)
        {
            Func<int, int, int> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static long GCD(long a, long b)
        {
            Func<long, long, long> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static ulong extGCD(ulong a, ulong b, ref ulong x, ref ulong y)
        {
            if (b == 0)
            {
                x = 1;
                y = 0;
                return a;
            }
            var d = extGCD(b, a % b, ref y, ref x);
            y -= a / b * x;
            return d;
        }
        public static int LCM(int a, int b) { return a * b / GCD(a, b); }
        public static long LCM(long a, long b) { return a * b / GCD(a, b); }
        public static long Inv(this long a, long m = MOD)
        {
            long b = m, u = 1, v = 0;
            while (b != 0)
            {
                long t = a / b;
                a -= t * b;
                swap(ref a, ref b);
                u -= t * v;
                swap(ref u, ref v);
            }
            u %= m;
            if (u < 0) u += m;
            return u;
        }
        private static void swap(ref long a, ref long b)
        {
            var t = a;
            a = b;
            b = t;
        }
        public static long ModPow(long a, long n, long m = MOD)
        {
            long res = 1;
            while (n > 0)
            {
                if (n % 2 == 1) res = (res * a) % m;
                a = (a * a) % m;
                n >>= 1;
            }
            return res;
        }

    }


}