"""
ID: oaimees1
LANG: PYTHON3
TASK: gift1
"""
fin = open ('gift1.in', 'r')
fout = open ('gift1.out', 'w')
lines = fin.read().splitlines()
NP = int(lines[0])
dic = {}
for i in range(1, NP + 1):
"""reading name of the group members"""
dic[lines[i]] = 0
readingNum = NP + 1
for i in range(NP):
''' reading name of the gift giver'''
gift_giver = lines[readingNum]
readingNum += 1
"""reading the amount of money and the number of people"""
tmp = lines[readingNum].split(' ')
readingNum += 1
amount = int(tmp[0])
NGi = int(tmp[1])
if NGi != 0:
avg = int(amount / NGi)
for j in range(NGi):
"""reading name of the gift reciver"""