Harryxun/stf_run huggingface dataset:
import sys
#limit=sys.getrecursionlimit()
sys.setrecursionlimit(100000)
#sys.setrecursionlimit(1000000000)

fileobj=open('subtask_1_28.txt','rt')

V=int(fileobj.readline().strip())
E=V-1
inf=3*10**15
G=[]
dist=[inf]*V
visited=[False]*V

for i in range(V):
    G.append([])
for i in range(E):
    at,bt,ct=map(int,fileobj.readline().strip().split(' '))
    G[at-1].append([ct,bt-1])
    G[bt-1].append([ct,at-1])

def dfs(v,p,d):
    #global d
    dist[v]=d
    visited[v]=True
    for q in G[v]:
        if q[1]==p:
            continue
        elif visited[q[1]]!=True:
            dfs(q[1],v,d+q[0])

Q, K=map(int,fileobj.readline().strip().split(' '))
K-=1 #0-indexedに直す

dfs(K,-1,0)

x=[]
y=[]

for i in range(Q):
    xt, yt=map(int,fileobj.readline().strip().split(' '))
    x.append(xt-1)#0-indexedに直して入れる
    y.append(yt-1)#0-indexedに直して入れる
for i in range(Q):
    print(dist[x[i]]+dist[y[i]])


### FIXED CODE ###

import sys
#limit=sys.getrecursionlimit()
sys.setrecursionlimit(10000000)
#sys.setrecursionlimit(1000000000)

V=int(input().strip())
E=V-1
inf=3*10**15
G=[]
dist=[inf]*V

for i in range(V):
    G.append([])
for i in range(E):
    at,bt,ct=map(int,input().strip().split(' '))
    G[at-1].append([ct,bt-1])
    G[bt-1].append([ct,at-1])

visited=[False]*V
def dfs(v,p,d):
    #global d
    dist[v]=d
    for q in G[v]:
        if q[1]==p:
            continue
        dfs(q[1],v,d+q[0])

Q, K=map(int,input().strip().split(' '))
K-=1 #0-indexedに直す

dfs(K,-1,0)

x=[]
y=[]

for i in range(Q):
    xt, yt=map(int,input().strip().split(' '))
    x.append(xt-1)#0-indexedに直して入れる
    y.append(yt-1)#0-indexedに直して入れる
for i in range(Q):
    print(dist[x[i]]+dist[y[i]])
def printer(n):
    if n%10 in [2,4,5,7,9]:print"hon"
    elif n%10 in[0,1,6,8]:print"pon"
    else:print"bon"
printter(int(input()))

### FIXED CODE ###

def printer(n):
    if n%10 in [2,4,5,7,9]:print("hon")
    elif n%10 in[0,1,6,8]:print("pon")
    else:print("bon")
printer(int(input()))
n,k = map(int,input().split())


import math

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


for i in range(1,k+1):
    print(i)
    print((combinations_count(n-k+1,i)*combinations_count(k-1,i-1))%(10**9+7))

### FIXED CODE ###

n,k = map(int,input().split())


import math

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


for i in range(1,k+1):
    if n-k+1>=i:
        red = combinations_count(n-k+1,i)
    else:
        red = 0
    
    ls = [int(x) for x in range(1,)]

    
    print((red*combinations_count(k-1,i-1))%(10**9+7))
N, M = map(int, input().split())
     
    seikai = 0
    miss = 0
     
    seikai_list = []  ##既に正解した問題番号のリスト
    input_list = [[0 for i in range(2)] for j in range(M)]  ##入力のリスト 問題番号と正誤
     
    for i in range(M):
      tmp = input().split()
      input_list[i][0] = tmp[0]
      input_list[i][1] = tmp[1]
     
    a = False
     
    for i in range(M):
      if input_list[i][1] =='AC':
          if (input_list[i][0] in seikai_list) == False:   ##正解リストの中に無ければ
            seikai += 1
            
            for k in range(i):
              if input_list[k][0] == input_list[i][0]:
                if input_list[k][1] == 'WA':
                  miss += 1
                    
            seikai_list.append(input_list[i][0])
                
    print("{} {}".format(seikai, miss))

### FIXED CODE ###

C = input()
alpha = 'abcdefghijklmnopqrstuvwxyz'
index = alpha.index(C)
print(alpha[index + 1])
x, y, z = map(int, input().split())

s = list(x, y, z)

print(sorted(s))


### FIXED CODE ###

#print(*sorted(map(int, input().split())))

print(*sorted(map(int, input().split())))
def solve():
    N, W = map(int, input().split())
    MAX_V = 100000
    MAX_N = 100
    w = []
    v = []
    for i in range(N):
        tmpw, tmpv = map(int, input().split())
        w.append(tmpw)
        v.append(tmpv)

    dp = [[float('inf') for i in range(MAX_V+1)] for j in range(MAX_N+1)]

    dp[0][0] = 0

    for i in range(N):
        for sum_v in range(MAX_V):
            if sum_v - v[i] >= 0:
                dp[i+1][sum_v] = min(dp[i+1][sum_v], dp[i][sum_v - v[i]] + w[i])
            
            dp[i+1][sum_v] = min(dp[i+1][sum_v], dp[i][sum_v])
        
    res = 0
    for sum_v in range(MAX_V+1):
        if dp[N][sum_v] <= W:
            res = sum_v
    print(res)

if __name__ == '__main__':
    solve()

### FIXED CODE ###

def solve():
    h, n = map(int, input().split())
    l = [list(map(int, input().split())) for i in range(n)]

    mxA = 10 ** 4
    dp = [[10**15 for i in range(h+1+mxA)] for i in range(n+1)]

    for i in range(n+1):
        dp[i][0] = 0

    for i in range(n):
        for sum_dam in range(h+1+mxA):
            if sum_dam-l[i][0]>=0:
                dp[i+1][sum_dam] = min(dp[i+1][sum_dam],  \
                                dp[i][sum_dam - l[i][0]] + l[i][1],  \
                                dp[i+1][sum_dam-l[i][0]] + l[i][1])
            dp[i+1][sum_dam] = min(dp[i+1][sum_dam], dp[i][sum_dam])

    print(min(dp[-1][h:h+mxA+1]))

if __name__ == '__main__':
    solve()
import itertools
costs = [int(x) for x in input().split()]
ans = 1000000000000
for x in itertools.permutations([0, 1, 2, 3, 4]):
  c = 0
  for i in range(0, 5):
    c += costs[x[i]]
    if i != 4 and c % 10 != 0:
      c += 10 - c % 10
  ans = min(c, ans)
print(ans)

### FIXED CODE ###

import itertools
costs = [int(input()) for _ in range(0, 5)]
ans = 1000000000000
for x in itertools.permutations([0, 1, 2, 3, 4]):
  c = 0
  for i in range(0, 5):
    c += costs[x[i]]
    if i != 4 and c % 10 != 0:
      c += 10 - c % 10
  ans = min(c, ans)
print(ans)
D_0 = list(range(1,100))
D_1 = list(range(100,10000,100))
D_2 = list(range(10000,1000000,10000))
D,N = map(int,input().split())
if D == 0:
  print(D_0[N-1])
elif D == 1:
  print(D_1[N-1])
else:
  print(D_2[N-1])

### FIXED CODE ###

D,N = map(int,input().split())
if N == 100:
    N += 1
print(N*(100**D))
from collections import*
n=int(input())
s=input()
c=0
r=s.count('R')
g=s.count('G')
b=s.count('B')
rgb=r*g*b

for i in range(n):
    for j in range(i+1,n):
        k=2*(j-i) 
        if k<=n and s[k]!=s[i] and s[k]!=s[j] and s[i]!=s[j]:
            rgb-=1

print(rgb)

### FIXED CODE ###

from collections import*
n=int(input())
s=input()
c=0
r=s.count('R')
g=s.count('G')
b=s.count('B')
rgb=r*g*b

for i in range(n-2):
    for j in range(i+1,n-1):
        k=2*j-i 
        if k<n and s[k]!=s[i] and s[k]!=s[j] and s[i]!=s[j]:
            rgb-=1

print(rgb)
import sys
input = sys.stdin.readline

N = int(input())
G = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = map(lambda x: int(x)-1, input().split())
    G[a].append(b)
    G[b].append(a)
group = [-1] * N
count = [0, 0]
stack = []
group[0] = 0
count[0] = 1
stack.append(0)
while stack:
    u = stack.pop()
    for v in G[u]:
        if group[v] == -1:
            group[v] = 1 - group[u]
            count[group[v]] += 1
            stack.append(v)
zeros = list(range(3, N+1, 3))
ones = list(range(1, N+1, 3))
twos = list(range(2, N+1, 3))
ans = [0] * N
for g in range(2):
    if count[g] <= N//3:
        for i in range(N):
            if group[i] == 0:
                ans[i] = zeros.pop()
            else:
                if len(twos) > 0:
                    ans[i] = twos.pop()
                elif len(ones) > 0:
                    ans[i] = ones.pop()
                else:
                    ans[i] = zeros.pop()
        print(' '.join(map(str, ans)))
        exit()
for i in range(N):
    if group[i] == 0 and len(ones) > 0:
        ans[i] = ones.pop()
    elif group[i] == 1 and len(twos) > 0:
        ans[i] = twos.pop()
    else:
        ans[i] = zeros.pop()
print(' '.join(map(str, ans)))


### FIXED CODE ###

import sys
input = sys.stdin.readline

N = int(input())
G = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = map(lambda x: int(x)-1, input().split())
    G[a].append(b)
    G[b].append(a)
group = [-1] * N
count = [0] * 2
stack = []
group[0] = 0
count[0] = 1
stack.append(0)
while stack:
    u = stack.pop()
    for v in G[u]:
        if group[v] == -1:
            group[v] = 1 - group[u]
            count[group[v]] += 1
            stack.append(v)
zeros = list(range(3, N+1, 3))
ones = list(range(1, N+1, 3))
twos = list(range(2, N+1, 3))
ans = [0] * N
for g in range(2):
    if count[g] <= N//3:
        for i in range(N):
            if group[i] == g:
                ans[i] = zeros.pop()
            else:
                if len(twos) > 0:
                    ans[i] = twos.pop()
                elif len(ones) > 0:
                    ans[i] = ones.pop()
                else:
                    ans[i] = zeros.pop()
        print(' '.join(map(str, ans)))
        exit()
for i in range(N):
    if group[i] == 0 and len(ones) > 0:
        ans[i] = ones.pop()
    elif group[i] == 1 and len(twos) > 0:
        ans[i] = twos.pop()
    else:
        ans[i] = zeros.pop()
print(' '.join(map(str, ans)))
import itertools
import numpy as np

# = int(input())
N, M, X = map(int, input().split())
# = list(map(int, input().split()))
# = [int(input()) for i in range(N)]
CA = [list(map(int, input().split())) for i in range(N)]

cost = []

nums=[]
for i in range(1, M+1):
    nums.append(i)

skill = list(zip(*CA))

for i in range(1, M+1):
    if sum(skill[i]) < X:
        print(-1)
        exit()

for i in range(N):
    for balls in list(itertools.combinations(CA, i)):
        test = np.zeros(M+1)
        for j in balls:
            jtest = np.asarray(j)
            test = test + jtest

        if min(test[1:])>=X:
            cost.append(test[0])

print(int(min(cost)))


### FIXED CODE ###

import itertools
import numpy as np

# = int(input())
N, M, X = map(int, input().split())
# = list(map(int, input().split()))
# = [int(input()) for i in range(N)]
CA = [list(map(int, input().split())) for i in range(N)]

cost = []

skill = list(zip(*CA))

for i in range(1, M+1):
    if sum(skill[i]) < X:
        print(-1)
        exit()

for i in range(1, N+1):
    for balls in list(itertools.combinations(CA, i)):
        test = np.zeros(M+1)
        for j in balls:
            jtest = np.asarray(j)
            test = test + jtest

        if min(test[1:])>=X:
            cost.append(test[0])

print(int(min(cost)))
class UnionFind:

    def __init__(self):
        self.parents = {}
        self.sz = {}
        self.size = 0


    def add(self, a):
        if a in self.parents:
            return
        self.size += 1
        self.sz[a] = 1
        self.parents[a] = a 

    def find(self, a):
        if self.parents[a] != a:
            self.parents[a] = self.find(self.parents[a])

        return self.parents[a]

    def join(self, a, b):
        pa, pb = self.find(a), self.find(b)
        if pa == pb:
            return
        if self.sz[pa] > self.sz[pb]:
            self.parents[pb] = pa
            self.sz[pa] += self.sz[pb]
        else:
            self.parents[pa] = pb 
            self.sz[pb] += self.sz[pa]

        self.size -= 1


n,m = list(map(int,input().split(" ")))
uf = UnionFind()
ans = 0
for _ in range(m):
    x,y = list(map(int,input().split(" ")))
    uf.add(x)
    uf.add(y)
    uf.join(x,y)
    ans = max(ans, uf.sz[x])


print(max(uf.sz.values()))


### FIXED CODE ###

class UnionFind:

    def __init__(self):
        self.parents = {}
        self.sz = {}
        self.size = 0


    def add(self, a):
        if a in self.parents:
            return
        self.size += 1
        self.sz[a] = 1
        self.parents[a] = a 

    def find(self, a):
        if self.parents[a] != a:
            self.parents[a] = self.find(self.parents[a])

        return self.parents[a]

    def join(self, a, b):
        pa, pb = self.find(a), self.find(b)
        if pa == pb:
            return
        if self.sz[pa] > self.sz[pb]:
            self.parents[pb] = pa
            self.sz[pa] += self.sz[pb]
        else:
            self.parents[pa] = pb 
            self.sz[pb] += self.sz[pa]

        self.size -= 1


n,m = list(map(int,input().split(" ")))
uf = UnionFind()
ans = 0
if m == 0:
    print(1)
else:
    for _ in range(m):
        x,y = list(map(int,input().split(" ")))
        uf.add(x)
        uf.add(y)
        uf.join(x,y)
        ans = max(ans, uf.sz[x])

    print(max(uf.sz.values()))
# region header
import sys
import math
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, deque, Counter
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import accumulate, groupby, product, permutations, combinations, combinations_with_replacement
from math import ceil, floor, factorial, log, sqrt, sin, cos
from operator import itemgetter
from string import ascii_lowercase, ascii_uppercase, digits
sys.setrecursionlimit(10**7)
rs = lambda: sys.stdin.readline().rstrip()
ri = lambda: int(rs())
rf = lambda: float(rs())
rs_ = lambda: [_ for _ in rs().split()]
ri_ = lambda: [int(_) for _ in rs().split()]
rf_ = lambda: [float(_) for _ in rs().split()]
INF = float('inf')
MOD = 10 ** 9 + 7
PI = math.pi
# endregion
N = ri()
S = list(Counter(ri_()))
print('Three' if len(S) == 3 else 'Four')

### FIXED CODE ###

# region header
import sys
import math
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, deque, Counter
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import accumulate, groupby, product, permutations, combinations, combinations_with_replacement
from math import ceil, floor, factorial, log, sqrt, sin, cos
from operator import itemgetter
from string import ascii_lowercase, ascii_uppercase, digits
sys.setrecursionlimit(10**7)
rs = lambda: sys.stdin.readline().rstrip()
ri = lambda: int(rs())
rf = lambda: float(rs())
rs_ = lambda: [_ for _ in rs().split()]
ri_ = lambda: [int(_) for _ in rs().split()]
rf_ = lambda: [float(_) for _ in rs().split()]
INF = float('inf')
MOD = 10 ** 9 + 7
PI = math.pi
# endregion
N = ri()
S = list(Counter(rs_()))
print('Three' if len(S) == 3 else 'Four')
inp = raw_input().split("\n")
Size = inp[0]

Mml = [None, 0] + [None] * 8
Cij = []
for i in xrange(10):
    Cij.append(inp[i + 1].split(" "))

def sloveMm(n):
    global Mml
    if(Mml[n] != None):
        return Mml[n]
    Nmm = Cij[n][1]
    rourt = [(n, 0, Nmm)]
    while len(rourt) > 0:
        rl = len(rourt)
        for rn in xrange(rl):
            r = rourt[rn]
            for i in xrange(10):
                nm = r[1] + Cij[n][i]
                if nm < r[2]:
                    if Mml[i] != None:
                        return nm + Mml[i]
                    if i == 1:
                        Nmm = nm
                    rourt.append((i, nm, nm + Cij[i][1]))
        for i in xrange(rl):
            rourt.remove(i)
    Mml = Nmm


NumberList = [0] * 10
for Ai in inp[12:]:
    for A in Ai.split(" "):
        if A != -1:
            NumberList[A] += 1

ans = 0
for i, n in enumerate(NumberList):
    ans += sloveMm(i) * n
print ans


### FIXED CODE ###


inp = []
inp.append(raw_input())
for i in xrange(10 + int(inp[0].split(" ")[0])):
    inp.append(raw_input())
Size = inp[0]

Mml = [None, 0] + [None] * 8
Cij = [[0] * 10 for i in range(10)]
for i in xrange(10):
    for j, a in enumerate(map(int,inp[i + 1].split(" "))):
        Cij[i][j] = a
        #print a,
    #print

def sloveMm(n):
    global Mml
    if(Mml[n] != None):
        return Mml[n]
    Nmm = Cij[n][1]
    rourt = [[n, 0, Nmm,n]]
    while len(rourt) > 0:
        rl = len(rourt)
        new_rourt = []
        for rn in xrange(rl):
            r = rourt[rn]
            for i in xrange(10):
                if i != r[0]:
                    nm = r[1] + Cij[r[0]][i]
                    if nm < Nmm:
                        """if Mml[i] != None:
                            Mml[n] = nm + Mml[i]
                            return nm + Mml[i]"""
                        if i == 1:
                            #print r
                            Nmm = nm
                        new_rourt.append([i, nm, nm + Cij[i][1]] + r[3:] + [i] )
        rourt = new_rourt
    Mml[n] = Nmm
    return Nmm


NumberList = [0] * 10
for Ai in inp[11:]:
    #print Ai
    for A in Ai.split(" "):
        if A != "-1" and A != "":
            NumberList[int(A)] += 1

ans = 0
for i, n in enumerate(NumberList):
    if n > 0:
        ans += sloveMm(i) * n
        #print "AA",i,":",Cij[i][1],">>",Mml[i],"*", n
#print Mml
#print NumberList
print ans
# -*- coding: <encoding name> -*-

T, X = int(input())
print(T / X)

### FIXED CODE ###

# -*- coding: <encoding name> -*-
'''
T, X = int(input())
print(T / X)
'''
T, X = map(int, input().split())
print(T / X)
N=int(input())
A=list(map(int,input().split()))

A=list(set(A))

L=len(A)

if L==1:
    print(0)
    exit()

mx=max(A)

f=[1]*L

A.sort()

for i in range(N):
    if A[i]*2>mx:break
    for j in range(i+1,N):
        if A[j]%A[i]==0:
            f[j]=0

print(sum(f))


### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))

mx=max(A)
f=[True]*(mx+1)
chk=[0]*(mx+1)

for a in A:
    chk[a]+=1

for a in A:
    cnt=2
    while a*cnt<=mx:
        f[a*cnt]=False
        cnt+=1
ans=0
for a in A:
    if f[a]==True and chk[a]<=1:
        ans+=1
print(ans)
S = input()
T = input()
code = S

if (len(T) > S):
    for x in range(len(S)):
        if (S[x] == '?'):
            code = code[:x] + 'a' + code[x+1:]
    for x in range(len(S)-(len(T)-1),-1,-1):
        if (x == -1):
            print('UNRESTORABLE')
        elif (S[x:x+len(T)] == (('?')*len(T)) or (S[x:x+len(T)] == ( T[0] + (('?')*(len(T)-1))))):
            code = code[:x] + T + code[x+len(T):]
            print(code)
else:
    print('UNRESTORABLE')

### FIXED CODE ###

def search(S,T):
    match = 0
    maxmatch = 0
    maxmatchloc = -1
    for x in range(len(S)-(len(T)-1)):
        match = 0
        if (S[x] == T[0] or S[x] == '?'):
            for i in range(0,len(T)):
                ##print(S[x+i] + '-' + T[i])
                if (S[x+i] == T[i] or S[x+i] == "?"):
                    match += 1
                else:
                    ##print("Entered!")
                    match = 0
                    break
            if (match >= maxmatch and match != 0):
                ##print("ENTERED")
                maxmatchloc = x
                maxmatch = match
        ##print('At x = ' + str(x) + ': maxmatchlocation is ' + str(maxmatchloc) + ' match is ' + str(match) + ' maxmatch is' + str(maxmatch))
    return maxmatchloc

S = input()
T = input()
code = S
if '?' in S:
    if (len(T) <= len(S)):
        startpoint = search(S,T)
        for x in range(len(S)):
            if (S[x] == '?'):
                code = code[:x] + 'a' + code[x+1:] 
        if(startpoint >= 0):
            code = code[:startpoint] + T + code[startpoint + len(T):]
            print(code)
        else:
            print('UNRESTORABLE')
    else:
        print('UNRESTORABLE')
else:
    print(S)
N=int(input())
array=list(map(int,input().split()))

A=[]
array=sorted(array)
for i in array:
    A.append(i)

dp=[True for i in range(N)]

if A[0]==A[1]:
    dp[0]=False
for i in range(N):
    for j in range(i+1,N):
        if A[j]%A[i]==0:
            dp[j]=False

num=0
for i in range(N):
    if dp[i] is True:
        num+=1

print(num)

### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))

M=1000050

dp=[0 for i in range(M)]

ans=0
for x in A:
    if dp[x]!=0:
        dp[x]=2
        continue
    for i in range(x,M,x):
        dp[i]+=1

for x in A:
    if dp[x]==1:
        ans+=1

print(ans)
s = input()
k = int(input())
i = 0
while s[i] == '1':
    i += 1
print(s[i] if i < k else 1)

### FIXED CODE ###

s = input()
k = int(input())
i = 0
while s[i] == '1':
    i += 1
    if i == len(s):
        break
print(s[i] if i < k else 1)
friend_dic = {}
block_dic = {}

N, M, K = map(int, input().split())

for i in range(N):
    friend_dic[i+1] = []
    block_dic[i+1] = []

for _ in range(M):
    a, b = map(int, input().split())
    friend_dic[a].append(b)
    friend_dic[b].append(a)

for _ in range(K):
    a, b = map(int, input().split())
    block_dic[a].append(b)
    block_dic[b].append(a)

def search_friends(n, friends):
    searched.append(n)
    for my_friend in friend_dic[n]:
        if my_friend not in friends:
            friends.append(my_friend)
            search_friends(my_friend, friends)

result = []
clusters = []
searched = []
for i in range(1, N+1):
    friends = []
    if i in searched:
        for cluster in clusters:
            if i in cluster:
                friends_set = cluster
                break
    else:
        search_friends(i, friends)
        friends_set = set(friends)
        clusters.append(friends_set)
    result.append(str(len(friends_set-set(friend_dic[i])-set(block_dic[i])-{i})))

print(" ".join(result))


### FIXED CODE ###

class UnionFind:
    """
    parents: 各要素の親要素
             要素がrootの場合には　-(そのグループに属する要素数) を格納
    """
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        # xが属するグループのrootを取得
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        # 高い方の木の根に低い方の木の根を結合
        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return - self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

      
n, m, k = map(int, input().split())

union_find = UnionFind(n)
friends_counter = {i: 0 for i in range(n)}
blocks_counter = {i: 0 for i in range(n)}

for _ in range(m):
    a, b = map(int, input().split())
    union_find.union(a-1, b-1)
    friends_counter[a-1] += 1
    friends_counter[b-1] += 1

for _ in range(k):
    c, d = map(int, input().split())
    if union_find.same(c-1, d-1):
        blocks_counter[c-1] += 1
        blocks_counter[d-1] += 1

result = []
for i in range(n):
    result.append(str(union_find.size(i) - friends_counter[i] - blocks_counter[i] - 1))

print(" ".join(result))
from collections import defaultdict
import numpy as np

A, B, M = map(int, input().split())
a = np.array(list(map(int, input().split())))
b = np.array(list(map(int, input().split())))

C = defaultdict(int)

for i in range(M):
    x, y, c = map(int, input().split())
    C[tuple([x-1, y-1])] = c

ans = a.min() + b.min()

for c in C:
    ans = min(ans, a[c[0]] + b[c[0]] - C[c])
    
print(ans)

### FIXED CODE ###

from collections import defaultdict
import numpy as np

A, B, M = map(int, input().split())
a = np.array(list(map(int, input().split())))
b = np.array(list(map(int, input().split())))

ans = a.min() + b.min()

for i in range(M):
    x, y, c = map(int, input().split())
    ans = min(ans, a[x-1] + b[y-1] - c)

print(ans)