Harryxun/stf_run huggingface dataset:
x, y, z, k = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
D = []
E = []
for i in range(x):
  for j in range(y):
    D.append(A[i]+B[j])
D.sort()
for i in range(z):
  for j in range(1, k+1):
    E.append(C[i]+D[-j])
print("\n".join(map(str,sorted(E)[::-1][:k])))


### FIXED CODE ###

x, y, z, k = [int(n) for n in input().split()]
va = sorted([int(n) for n in input().split()], reverse=True)
vb = sorted([int(n) for n in input().split()], reverse=True)
xy = min(x*y, k)
vab = (sorted([a + b for a in va for b in vb], reverse=True))[:xy]
vc = sorted([int(n) for n in input().split()], reverse=True)
xyz = min(x*y*z, k)
print(*((sorted([ab + c for ab in vab for c in vc], reverse=True))[:xyz]), sep="\n")
n, m = map(int, input().split())

array = [int(x) for x in input().split()]
res = sorted(array)
judge = False
tmp = res.pop(0)
for i in res:
  if i%tmp != 0:
    judge = True
    break
if res[-1] < m:
  judge = False
print("POSSIBLE" if judge else "IMPOSSIBLE")


### FIXED CODE ###

import fractions
import sys

n, k = map(int, input().split())
array = [int(x) for x in input().split()]

if n == 1:
    print("POSSIBLE" if max(array) == k else "IMPOSSIBLE")
    sys.exit()

res = fractions.gcd(array[0], array[1])

for i in array[2:]:
    res = fractions.gcd(res, i)
print("POSSIBLE" if k%res==0 and max(array) >= k else "IMPOSSIBLE")
N = int(input())
A = list(map(int, input().split()))
M = 100005
cnt = [0]*M
ans = 0
for a in A:
    if cnt[a] == 1:
        cnt[a] = 2
    else:
        for i in range(a, M, a):
            cnt[i] += 1
for a in A:
    if cnt[a] == 1:
        ans += 1
print(ans)


### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
M = max(A)+1
cnt = [0]*M
ans = 0
for a in A:
    if cnt[a] != 0:
        cnt[a] = 2
    else:
        for i in range(a, M, a):
            cnt[i] += 1
for a in A:
    if cnt[a] == 1:
        ans += 1
print(ans)
r= int(input())
??= 3.141592653589793238
print(??*r**2,2*??*r)

### FIXED CODE ###

from math import pi
r = float(input())
print(round(r * r * pi, 7), round(2 * pi * r, 7))
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

class BIT():
    def __init__(self, max_n):
        self.size = max_n + 1
        self.tree = [0] * self.size

    def get_sum(self,i):
        s = 0
        while i:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, x):
        while i < self.size:
            self.tree[i] += x
            i += i & -i

n,q = map(int,readline().split())
c = list(map(int,readline().split()))
lr = list(map(int,read().split()))
it = iter(lr)
lr2 = [[0,0,0] for _ in range(n)]
for i,l,r in zip(range(q),it,it):
    lr2[i] = [r-1,l-1,i]

lr2.sort()
st = BIT(n+1)
ans = [0] * q
before = [-1] * (n+1)
c_ind = 0
for r,l,i in lr2:
    while(c_ind <= r):
        bef = before[c[c_ind]]
        if(bef!=-1):
            st.add(bef+1,-1)
        before[c[c_ind]] = c_ind
        c_ind += 1

    ans[i] = r-l+1 + st.get_sum(r+1) - st.get_sum(l)

print('\n'.join(map(str,ans)))

### FIXED CODE ###

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

class Seg_sum():
    def __init__(self,x):
        #####単位元######
        self.ide_ele_min = 0
        self.func = lambda a,b : a+b

        self.n = len(x)

        #num_max:n以上の最小の2のべき乗
        self.num_max =2**(self.n-1).bit_length()
        self.x = [self.ide_ele_min]*2*self.num_max

        for i,num in enumerate(x, self.num_max):
            self.x[i] = num
        for i in range(self.num_max-1,0,-1):
            self.x[i] = self.func(self.x[i<<1],self.x[(i<<1) + 1])

    def update(self,i,x):
        i += self.num_max
        self.x[i] = x
        while(i>0):
            i = i//2
            self.x[i] = self.func(self.x[i<<1],self.x[(i<<1) + 1])

    def query(self,i,j):
        res = self.ide_ele_min
        if i>=j:
            return res
        i += self.num_max
        j += self.num_max -1
        while(i<=j):
            if(i==j):
                res = self.func(res,self.x[i])
                break
            if(i&1):
                res = self.func(res,self.x[i])
                i += 1
            if(not j&1):
                res = self.func(res,self.x[j])
                j -= 1
            i = i>>1
            j = j>>1
        return res

n,q = map(int,readline().split())
c = tuple(map(int,readline().split()))
lr = tuple(map(int,read().split()))
it = iter(lr)
lrq = [[] for _ in range(n)]
for i,l,r in zip(range(q),it,it):
    lrq[r-1].append((l-1,i))

st = Seg_sum([1]*(n+1))
ans = [0] * q
before = [-1] * (n+1)
c_ind = 0
for r in range(n):
    for l,i in lrq[r]:
        while(c_ind <= r):
            bef = before[c[c_ind]]
            if(bef!=-1):
                st.update(bef,0)
            before[c[c_ind]] = c_ind
            c_ind += 1

        ans[i] = st.query(l,r+1)

print('\n'.join(map(str,ans)))
n,a,b,c,d=map(int, input().split())
s=input()
v=0
x=0
for i in range(n-2):
    if c<d:
        if i>b and i<d and s[i]=='#' and s[i+1]=='#':
            print('No')
            v+=1
            break

    
    elif c>d:
        if  i>=b-1 and i<d+1 and s[i]=='.' and  s[i+1]=='.' and s[i+2]=='.' :
            x=1
            break
if c>d and x==0:
    print('No')
            
if x==1:
    for i in range(n-2):
        if i>b and i<c and s[i]=='#' and s[i+1]=='#':
            print('No')
            v+=1
            break
    if v==0:

### FIXED CODE ###

n, a, b, c ,d = map(int, input().split())
s = input()[:max(c,d)]
 
def main():
    if "##" in s[b:d-2]:
        return "No"
    if "##" in s[a:c-2]:
        return "No"
 
    if c < d:
        return "Yes"
    
    else:
 
        if "..." in s[b-2:d+1]:
            return "Yes"
                
        return "No"
 
print(main())
s = input()
if s[3] = s[2] and s[4] = s[5]:
  print('Yes', end = '')
else:
  print('No',end = '')

### FIXED CODE ###

s = input()
if s[3] == s[2] and s[4] == s[5]:
  print('Yes', end = '')
else:
  print('No',end = '')
def around(K,A):
    N2 = A.pop(0)
    A.append(N2+K)
    return A

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

X = 0
X_min = 1000000000
for j in range(0,len(A)):
    X=
    X = A[len(A)-1] - A[0]
    if X_min > X:
        X_min = X
    A=around(K,A)
    
print(X_min)

### FIXED CODE ###

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

X = 0
space = 0
idx = 0
A.append(A[0]+K)
for j in range(0,len(A)-1):
    X=0
    X = A[j+1] - A[j]
    if space < X:
        space = X
        idx = j
    
print(A[idx] + K - A[idx+1] )
MOD = (10**9 + 7)
broken_step = []
     
line = [int(s) for s in input().split()]
     
N, M = line[0], line[1]
     
for i in range(M):
    step_num = int(input().split()[0])
    broken_step.append(step_num)
        
        
dp = [0]*(N+1)
dp[0] = 1
if 1 in broken_step:
    dp[1] = 0
else:
    dp[1] = 1
     
for i in range(2, N+1):
    dp[i] = (dp[i-1]+dp[i-2])%MOD if i not in broken_step else 0
print(dp[N])

### FIXED CODE ###

M = [int(s) for s in input().split()]

print(sum(M)-max(M))
N = input()
num = input().split()

count = 0
while(True):
	div = []
	for i in num:
	if(i % 2 == 0)
    	div.append(i/2)
    else:
	  	print(count)
        break
	num = div
	count = count + 1



### FIXED CODE ###

n = input()
num = [int(i) for i in input().split()]
count = 0
end=False
while(True):
	div = []
	for i in num:
		if(i % 2 == 0):
			div.append(i/2)
		else:
			print(count)
			end = True
			break
	if(end == True):
		break
	num = div
	count = count + 1
n = int(input())
a = list(map(int,input().split()))
a1 = {}
a2 = {}

for i in range(0,n//2+1,2):
    if str(a[i]) in a1.keys():
        a1[str(a[i])] += 1
    else :
        a1[str(a[i])] = 1
    if str(a[i+1]) in a2.keys():
        a2[str(a[i+1])] += 1
    else :
        a2[str(a[i+1])] = 1

a1 = sorted(a1.items(), key=lambda x: -x[1])
a2 = sorted(a2.items(), key=lambda x: -x[1])

if a1[0][0] == a2[0][0]:
    print(n-max(a1[0][1]+a2[1][1],a1[1][1]+a2[0][1]))
else :
    print(n-a1[0][1]-a2[0][1])

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
a1 = {'emp':0}
a2 = {'emp':0}

for i in range(0,n,2):
    # print(i)
    if str(a[i]) in a1.keys():
        a1[str(a[i])] += 1
    else :
        a1[str(a[i])] = 1
    if str(a[i+1]) in a2.keys():
        a2[str(a[i+1])] += 1
    else :
        a2[str(a[i+1])] = 1
# print(a1,a2)

a1 = sorted(a1.items(), key=lambda x: -x[1])
a2 = sorted(a2.items(), key=lambda x: -x[1])

# print(a1,a2)
if a1[0][0] == a2[0][0]:
    print(n-max(a1[0][1]+a2[1][1],a1[1][1]+a2[0][1]))
else :
    print(n-a1[0][1]-a2[0][1])
n, k = map(int, input().split())
a = list(map(int,input().split()))

a_p =[]
a_m =[]
for i in a:
    if i >= 0:
        a_p.append(i)
    else :
        a_m.append(i)

a_p.sort()
a_m.sort(reverse=True)


a_select =[]

if n == k:
    a_select = a

if len(a_p) == 0:
    for i in range(k):
        a_select.append(a_m[i])


while len(a_select) < k:
    if len(a_select) == k - 1:
        a_select.append(a_p[-1])
        break
    if len(a_p) == 1 and (k-len(a_select))%2 == 1:
        a_select.append(a_p[-1])
    elif len(a_p) == 0:
        a_select.append(a_m.pop(-1))
        a_select.append(a_m.pop(-1))
    elif len(a_m) <= 1:
        a_select.append(a_p.pop(-1))
    elif a_p[-1]*a_p[-2] > a_m[-1]*a_m[-2] :
        a_select.append(a_p.pop(-1))
    else:
        a_select.append(a_m.pop(-1))
        a_select.append(a_m.pop(-1))

#print(a_select)
ans = 1
for i in a_select:
    ans = ans*i % (10**9 + 7)

print(ans)


### FIXED CODE ###

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

a_p =[]
a_m =[]
for i in a:
    if i >= 0:
        a_p.append(i)
    else :
        a_m.append(i)

a_p.sort()
a_m.sort(reverse=True)


a_select =[]

if n == k:
    a_select = a
elif len(a_p) == 0 and k%2 == 1:
    for i in range(k):
        a_select.append(a_m[i])


while len(a_select) < k:
    if len(a_select) == k - 1:
        a_select.append(a_p[-1])
        break
    if len(a_p) == 1 and (k-len(a_select))%2 == 1:
        a_select.append(a_p.pop(-1))
    elif len(a_p) == 1 and (k-len(a_select))%2 == 0:
        a_select.append(a_m.pop(-1))
        a_select.append(a_m.pop(-1))
    elif len(a_p) == 0:
        a_select.append(a_m.pop(-1))
        a_select.append(a_m.pop(-1))
    elif len(a_m) <= 1:
        a_select.append(a_p.pop(-1))
    elif a_p[-1]*a_p[-2] > a_m[-1]*a_m[-2] :
        a_select.append(a_p.pop(-1))
    else:
        a_select.append(a_m.pop(-1))
        a_select.append(a_m.pop(-1))

#print(a_select)
ans = 1
for i in a_select:
    ans = ans*i % (10**9 + 7)

print(ans)
n = int(input())
a = []
for i in range(n):
    s, p = input().split()
    p = int(p)
    a.append((s, -int(p), i))
a.sort()

for _, _, i in a:
    print(i + 1)

### FIXED CODE ###

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

print((3 * A + P) // 2)
N = int(input())
X = list(map(int,input().split()))
S = []
for p in range(min(X), max(X)):
    t = [(i - p) ** 2 for i in X]
    S.append(sum(t))
print(min(S))


### FIXED CODE ###

N = int(input())
X = list(map(int,input().split()))
S = []
for p in range(min(X), (max(X) + 1)):
    t = [(i - p) ** 2 for i in X]
    S.append(sum(t))
print(min(S))
from collections import defaultdict

def dfs(i, V, E, num):
    V[i] = num
    for j in E[i]:
        if V[j] > 0:
            continue
        V = dfs(j, V, E, num)
    return V

n, k, l = map(int, input().split())
Er = defaultdict(list)
for i in range(k):
    p, q = map(int, input().split())
    Er[p].append(q)
    Er[q].append(p)
Et = defaultdict(list)
for i in range(l):
    r, s = map(int, input().split())
    Et[r].append(s)
    Et[s].append(r)

Vr_group = [None]
Vr = [0 for _ in range(n + 1)]
j = 1
for i in range(1, n + 1):
    if Vr[i] > 0:
        continue
    Vr = dfs(i, Vr, Er, j)
    Vr_group.append({t for t in range(1, n + 1) if Vr[t] == j})
    j += 1

Vt_group = [None]
Vt = [0 for _ in range(n + 1)]
j = 1
for i in range(1, n + 1):
    if Vt[i] > 0:
        continue
    Vt = dfs(i, Vt, Et, j)
    Vt_group.append({t for t in range(1, n + 1) if Vt[t] == j})
    j += 1

ans = []
for i in range(1, n + 1):
    ans.append(len(Vr_group[Vr[i]] & Vt_group[Vt[i]]))
print(' '.join([str(x) for x in ans]))


### FIXED CODE ###

import sys
from collections import Counter

class UnionFind(object):
    def __init__(self, n):
        self.par = [i for i in range(n + 1)]
        self.rank = [0 for i in range(n + 1)]

    def find(self, x):
        if self.par[x] == x:
            return x
        self.par[x] = self.find(self.par[x])
        return self.par[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        elif self.rank[x] > self.rank[y]:
            self.par[y] = x
        else:
            self.par[y] = x
            self.rank[x] += 1

sys.setrecursionlimit(10 ** 5 + 1)

n, k, l = map(int, input().split())
Ur = UnionFind(n)
for i in range(k):
    p, q = map(int, input().split())
    Ur.union(p, q)

Ut = UnionFind(n)
for i in range(l):
    r, s = map(int, input().split())
    Ut.union(r, s)

x = [(Ur.find(i + 1), Ut.find(i + 1)) for i in range(n)]
c = Counter(x)
ans = []
for i in range(n):
    ans.append(c[x[i]])
print(' '.join([str(a) for a in ans]))
N = int(input())

flag = False
for i in range(N+1):
  if N%i == 0:
    if N//i < 10 and i < 10:
      flag = True
      break
      
if flag:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

N = int(input())

flag = False
for i in range(1, N+1):
  if N%i == 0:
    if N//i < 10 and i < 10:
      flag = True
      break
      
if flag:
  print('Yes')
else:
  print('No')
n = int(input());
ans = 1;
zero = false
for i in map(int, input().split()):
    ans *= i
    if i==0:
        zero = true
print(ans if ans>=0 else -1);


### FIXED CODE ###

n = int(input());
list = list(map(int,input().split()))
zero = False
for i in list:
    if i==0:
        zero = True
        break
if zero:
    print(0)
else:
    ans = 1
    for i in list:
        ans *= i
        if ans>10**18:
            ans = -1
            break
    print(ans)
a,b=input()
ptint(a)


### FIXED CODE ###

s = raw_input().split()
a = int(s[0])
b = int(s[1])
print("{0} {1}".format(a*b, 2*(a+b)))
def solve(N,M,S,C) -> int:
    if(N == 1): return min(C)
    dic = {key:[] for key in range(1,N+1)}
    ans = 10**5
    for s,c in zip(S,C):
        if(s in dic.keys()):
            dic[s].append(c)
        else:
            dic[s]=[c]
    if(N != 1):
        if(0 in dic[1]):
            dic[1].remove(0)
        for i in range(2,N+1):
            if(dic[i] == []):
                dic[i].append(0)
    if(dic[1]==[]):
        return -1
    else:
        ans = ""
        for values in dic.values():
            tmp = min(values)
            ans+= str(tmp)
        return int(ans)
    


def main():
    N,M = map(int,input().split())
    S = []
    C = []
    for _ in range(M):
        s,c = map(int,input().split())
        S.append(s)
        C.append(c)
    # solve()
    print(solve(N,M,S,C))
if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys
N,M=map(int,input().split())
SC=[]

for _ in range(M):
    s,c=map(int,input().split())
    SC.append([s,c])

ans=-1
for i in range(10**N):
    if(len(str(i)) == N):
        for j in range(M):
            s=SC[j][0] - 1
            c=SC[j][1]
            tmp=list(str(i))
            if(tmp[s] != str(c) ):
                break
        else:
            if(ans == -1):
                ans=i
            else:
                ans=min(ans,i)
print(ans)
dishes = [int(input()) for i in range(5)]

ans = 0
min_digits = 10
digits_idx = 0
for idx, dish in enumerate(dishes):
  ans += round(dish, -1)
  if dish%10 < mindigits:
    digits_idx = idx
  	min_digits = dish%10
ans = ans + dishes[digits_idx] - round(dishes[digits_idx], -1)
print(ans)

### FIXED CODE ###

dishes = [int(input()) for i in range(5)]

ans = 0
min_digits = 10
digits_idx = 0
for idx, dish in enumerate(dishes):
  if dish%10 == 0:
    ans += dish
  else:
    ans += dish + 10 - dish%10
  if dish%10 < min_digits and dish%10 !=0:
    digits_idx = idx
    min_digits = dish%10
if min_digits == 10:
  print(ans)
else:
  ans -= (10 - min_digits)
  print(ans)
a,b,c,d = map(int,input().split())
e = min([a,b])
f = min([c,d])
print(e+f)

### FIXED CODE ###

a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = min([a,b]) + min([c,d])
print(e)
from math import gcd
from functools import reduce

N = int(input())
T = [int(input()) for _ in range(N)]


def lcm(a, b):
    return a * b // gcd(a, b)


def lcm_multi(nums):
    return reduce(lcm, nums)


print(lcm_multi(T))

### FIXED CODE ###

from fractions import gcd
from functools import reduce

N = int(input())
T = [int(input()) for _ in range(N)]


def lcm(a, b):
    return a * b // gcd(a, b)


def lcm_multi(nums):
    return reduce(lcm, nums)


print(lcm_multi(T))
N = int(input())
M = int(input())
for i in range(M):
     N = N - int(input())
if N >= 0:
    print(N)
else:
    print(-1)

### FIXED CODE ###

N = input()
A = input()
M = [int(x) for x in N.split(' ')]
B = [int(x) for x in A.split(' ')]
for i in range(M[1]):
     M[0] = M[0] - B[i]
if M[0] >= 0:
    print(M[0])
else:
    print(-1)
def resolve():
    t = input()
    l = len(t)
    que = []
    ans = [""]
    ma = [0]

    def dfs(s, idx):
        if idx == l:
            a = s.count("D") + s.count("PD")
            if ma[0] < a:
                ans[0] = s
                ma[0] = a
            return

        if t[idx] == "?":
            dfs(s + "D", idx + 1)
        else:
            dfs(s + t[idx], idx + 1)

    dfs("", 0)
    print(ans[0])

resolve()

### FIXED CODE ###

def resolve():
    t = input()
    s = ""
    for c in t:
        if c == "?":
            c = "D"

        s += c
    print(s)

resolve()
a, b, k = map(int, input().split())

l = list(range(a, b + 1))
l_low = l[:k]
l_up = l[-k:]

ll = sorted(list(set(l_low + l_up)))

for i in ll:
    print(i)



### FIXED CODE ###

a, b, k = map(int, input().split())

a_upper = min(b, a+k-1)
b_lower = max(a, b-k+1)

u = set(range(a, a_upper+1))
v = set(range(b_lower, b+1))

for i in sorted(list(u | v)):
    print(i)
def main2():
    S=list(input())
    K=int(input())
    N=len(S)

    P=sorted(S)
    l=[]
    k=0
    while len(l)<=5:
        for n in range(N):
            if S[n]==P[k]:
                for i in range(1,6):
                    if n+i<N-1:
                        tmp="".join(S[n:n+i])
                        if tmp not in l:
                            l.append(tmp)
        k+=1
    l.sort()
    print(l[K-1])

if __name__=="__main__":
    main2()

### FIXED CODE ###

def main2():
    S=list(input())
    K=int(input())
    N=len(S)

    P=sorted(S)
    l=[]
    a=[]
    k=0
    while len(l)<=5 and k<N:
        if P[k] not in a:
            a.append(P[k])
            for n in range(N):
                if S[n]==P[k]:
                    for i in range(1,6):
                        if n+i<=N:
                            tmp="".join(S[n:n+i])
                            if tmp not in l:
                                l.append(tmp)
        k+=1
    l.sort()
    print(l[K-1])

if __name__=="__main__":
    main2()
n=int(input())
l=[]
for i in range(n):
  l.append(list(map(int,input().split())))
l1=[0,0,0]
b=True
for i in l:
  if abs(l[i][1]-l1[1])+abs(l1[2]-l[i][2])>l[i][0]-l1[0]:
    b=False
    break
  elif (abs(l[i][1]-l1[1])+abs(l1[2]-l[i][2]))%2!=(l[i][0]-l1[0])%2:
    b=False
    break
  else:
    l1=l[i]
if b:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

n=int(input())
l=[]
for i in range(n):
  l.append(list(map(int,input().split())))
l1=[0,0,0]
b=True
for i in range(n):
  if abs(l[i][1]-l1[1])+abs(l1[2]-l[i][2])>l[i][0]-l1[0]:
    b=False
    break
  elif (abs(l[i][1]-l1[1])+abs(l1[2]-l[i][2]))%2!=(l[i][0]-l1[0])%2:
    b=False
    break
  else:
    l1=l[i]
if b:
  print("Yes")
else:
  print("No")
N = list(map(int,input().split()))
math = N[0] * N[1]
 if math % 2 = 1
  return Odd
 else 
  return Even

### FIXED CODE ###

N = list(map(int,input().split()))
math = N[0] * N[1]
if math % 2 == 1:
  print("Odd")
else:
  print("Even")
import math as ma

a,b,h,m = map(int,input().split())

al = h*30
bl = m*6
dec = al-bl
dec = dec % 180
if dec < 0:
  dec *= -1
rad = dec * ma.pi / 180
r = ma.sqrt(a**2 + b**2 -2*a*b*ma.cos(rad))
print(r)

### FIXED CODE ###

a = int(input())
s = a % 10
print("hon" if s ==2 or s == 4 or s == 5 or 
      s == 7 or s == 9 else "pon" if 
      s == 0 or s == 1 or s == 6 or s == 8
      else "bon")
from collections import defaultdict
n = int(input())
seen = defaultdict(int)
for _ in range(n):
  s = sorted(input())
  seen[s]+=1

ans = 0
for i in seen:
  ans+= seen[i]*(seen[i]-1)//2
print(ans)

### FIXED CODE ###

from collections import defaultdict
n = int(input())
seen = defaultdict(int)
for _ in range(n):
  s = "".join(sorted(input()))
  seen[s]+=1

ans = 0
for i in seen:
  ans+= seen[i]*(seen[i]-1)//2
print(ans)
T,S = map(str,input().split())
A,B = map(int,input().split())
U = input()
Z = [A+[0,-1][U == T],B+[0,-1][U == S]]
P = " ".join(Z)
print(P)

    

### FIXED CODE ###

T,S = input().split()
A,B = map(int,input().split())
U = input()
Z = [A+[0,-1][U == T],B+[0,-1][U == S]]
O = map(str,Z)
agy = ' '.join(O)
print(agy)
a,b = map(int,input().split())

 if a < b:
   print('a < b')
 elif a == b:
   print('a == b')
 else:
   print('a > b')

### FIXED CODE ###

a,b = map(int,input().split())

if a < b:
   print('a < b')
elif a == b:
   print('a == b')
else:
   print('a > b')
s = str(input())
k = int(input())
c = 0
for i in range(len(s)):
    if s[i] == "1":
        c += 1
    else:
        continue
if c >= k:
    print(1)
    break
for i in range(len(s)):
    if s[i] != "1":
        print(s[i])
        break


### FIXED CODE ###

s = str(input())
k = int(input())
c = 0
for i in range(len(s)):
    if s[i] == "1":
        c += 1
    else:
        break

if c >= k:
    print("1")
else:
    for i in range(len(s)):
        if s[i] != "1":
            print(s[i])
            break
n=int(input())
v=input().split()
w=sorted(v)
a=1
x=int(w[0])
while a<=n-1:
  y=int(w[a])
  z=float(x)+float(y)
  x=float(z)/float(2)
  a=a+1
print(x)

### FIXED CODE ###

A=input()
s=input()
a=int(A)
if a>=3200:
  print(s)
else:
  print('red')
# union-find

import collections

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

list = [list(map(int, input().split())) for x in range(m)]

par = [i for i in range(n+1)]

for i in list:
    par[i[0]] = i[1]

def find(x):
    if par[x] == x:
        return x
    else:
        par[x] = find(par[x]) #経路圧縮
        return par[x]
      
for i in range(len(par)):
    find(i)

c = collections.Counter(par)

print(c.most_common()[0][1])


### FIXED CODE ###

# union-find

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

list = [list(map(int, input().split())) for x in range(m)]

#Union Find

#xの根を求める
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]
#xとyの属する集合の併合
def unite(x,y):
    x = find(x)
    y = find(y)

    if x == y:
        return False
    else:
        #sizeの大きいほうがx
        if par[x] > par[y]:
            x,y = y,x
        par[x] += par[y]
        par[y] = x
        return True

#xとyが同じ集合に属するかの判定
def same(x,y):
    return find(x) == find(y)

#xが属する集合の個数
def size(x):
    return -par[find(x)]

#初期化
#根なら-size,子なら親の頂点
par = [-1]*n

for i in list:
  unite(i[0]-1, i[1]-1)

max = 0

for i in range(len(par)):
    if max<size(i):
        max = size(i)
print(max)
while 1:
    x = input()
    if x[0] == 0:
        break
    print (sum(int(i)for i in x))

### FIXED CODE ###

while 1:
    x = input()
    if x[0] == "0":
        break
    print (sum(int(i)for i in x))