codd:
{
ID:victorl1
PROG:gift1
LANG:PASCAL
}
var
a:array[1..10,1..10]of integer;
b:array[1..10]of string;
i,j,n,m,k,t:integer;
s:string;
function sum(i:integer):integer;
begin
sum:=0;
for j:=1 to n do inc(sum,a[i,j]);
end;
function chose(s:string):integer;
var
i:integer;
begin
for i:=1 to n do if b=s then begin chose:=i;exit;end;
end;
begin
assign(input,'gift1.in');reset(input);
assign(output,'gift1.out');rewrite(output);
readln(n);
for i:=1 to n do readln(b);
for i:=1 to n do
begin
readln(s);
readln(m,k);
t:=chose(s);
a[t,t]:=-m;
for j:=1 to k do
begin
readln(s);
a[chose(s),t]:=m div k;
end;
end;
for i:=1 to n do writeln(b,' ',sum(i));
close(input);
close(output);
end.
[p:2]