program Taylor;
uses crt;
var n,max,l,k,a,i:longint; s,m:string;
begin
clrscr;
write('n=');readln(n);
for i:=1 to n*2 do
begin
write('Nhap vao danh sach:');readln(s);
val(copy(s,3,2),a);
if s[2]='A' then inc(k,a) else inc(l,a);
if a>max then begin max:=a; m:=s; end;
end;
if k>l then writeln('Lop 9A nhieu rac hon') else writeln('Lop 9B nhieu rac hon');
writeln('Nguoi co nhieu rac nhat o lop 9',m[2],', so ',m[5],m[6]);
readln
end.
///////////////////////////////////////
Test: