program lab14;
uses crt;
type Stud = record
Name,Group: String[100];
Data: Byte;
Gender: Char;
Teormeh1,Mathematica1,Phisics,Geometry:Byte;
Teormeh2,Mathematica2,Sopromat:Byte;
end;
var Student:Stud;
ft: file of Stud;
i,mat0,mat,phys0,phys,meh0,meh,geom0,geom,porivn1,porivn2,predmet:byte;
begin
clrscr;
writeln;
assign(ft,'stud.txt');
mat0:=0;
phys0:=0;
meh0:=0;
geom:=0;
for i:=1 to 2 do begin
read(ft,Student);
phys:=Student.Phisics;
phys0:=phys0+phys;
mat:=Student.Mathematica1;
mat0:=mat0+mat;
meh:=Student.Teormeh1;
meh0:=meh0+meh;
geom:=Student.Geometry;
geom0:=geom0+geom;
end;
if (mat0>phys0) then porivn1:=mat0
else porivn1:=phys0;
if (meh0>geom0) then porivn2:=meh0
else porivn2:=geom0;
if (porivn1>porivn2) then predmet:=porivn1
else predmet:=porivn2;
if (predmet=phys0) then writeln ('Физика');
if (predmet=mat0) then writeln ('Математика');
if (predmet=meh0) then writeln ('Механика');
if (predmet=geom0) then writeln ('Графика');
readkey;
close(ft);
end.