program ask14(input,output,f1,f2);
const size=15;
type string20=array [1..20] of char ;
student=record
Epitheto,Onoma : string20;
AM :integer
end;
lista=array[1..size] of student;
var f1,f2 : file of student;
w : lista;
i : integer;
procedure merge(var a,b,c : lista;
fa,la,fb,lb,fc:integer;
var lc:integer);
var ia,ib,ic : integer;
begin
ia:=fa;ib:=fb;ic:=fc;
repeat
if a[ia]<b[ib] then begin c[ic]:=a[ia];ia:=ia+1 end
else begin c[ic]:=b[ib];ib:=ib+1 end;
ic:=ic+1
until (ia>la) or (ib>lb);
for ia:=ia to la do begin c[ic]:=a[ia];ic:=ic+1 end;
for ib:=ib to lb do begin c[ic]:=b[ib];ic:=ic+1 end;
lc:=ic-1
end;
procedure mergesort(var a : lista;fa,la:integer);
var b:lista; i,mid:integer;
begin
if fa<la then
begin mid:=(fa+la) div 2;
mergesort(a,fa,mid);mergesort(a,mid+1,la);
merge(a,a,b,fa,mid,mid+1,la,fa,la);
for i:=fa to la do a[i]:=b[i]
end
end;
begin
rewrite(f1);
w[1].AM:=98901;w[1].Epitheto:=ΚΩΣΤΟΠΟΥΛΟΣ;w[1].Onoma:=ΝΙΚΟΛΑΟΣ;
w[2].AM:=98902;w[2].Epitheto:=ΔΙΑΜΑΝΤΙΔΗΣ;w[2].Onoma:=ΔΗΜΗΤΡΙΟΣ;
w[3].AM:=98806;w[3].Epitheto:=ΝΙΚΟΛΑΟΥ;w[3].Onoma:=ΠΕΤΡΟΣ;
w[4].AM:=98856;w[4].Epitheto:=ΠΑΠΑΔΙΑΜΑΝΤΗΣ;w[4].Onoma:=ΚΩΝΣΤΑΝΤΙΝΟΣ;
w[5].AM:=98847;w[5].Epitheto:=ΚΩΣΤΟΠΟΥΛΟΣ;w[5].Onoma:=ΔΗΜΗΤΡΙΟΣ;
w[6].AM:=98790;w[6].Epitheto:=ΕΥΣΤΡΑΤΙΟΥ;w[6].Onoma:=ΜΑΡΙΑ;
w[7].AM:=98791;w[7].Epitheto:=ΔΗΜΗΤΡΙΟΥ;w[7].Onoma:=ΑΛΕΞΑΝΔΡΑ;
w[8].AM:=98999;w[8].Epitheto:=ΚΩΣΤΟΠΟΥΛΟΥ;w[8].Onoma:=ΙΩΑΝΝΑ;
w[9].AM:=98903;w[9].Epitheto:=ΔΙΑΜΑΝΤΙΔΗΣ;w[9].Onoma:=ΔΗΜΗΤΡΙΟΣ;
w[10].AM:=98907;w[10].Epitheto:=ELGHALI;w[10].Onoma:=ABDULLAH;
w[11].AM:=98990;w[11].Epitheto:=ΠΑΠΑΔΙΑΜΑΝΤΟΠΟΥΛΟΣ;w[11].Onoma:=ΑΛΕΞΑΝΔΡΟΣ;
writeln(f1,w[i]);
close(f1);
reset(f1);rewrite(f2);read(f1,w[i]);
for i:=1 to size do
begin
write(w[i].Onoma:20);write(w[i].Epitheto:20);write(w[i].AM:6);
end;
mergesort(w,1,size);writeln;writeln;
for i:=1 to size do
begin
write(f2,w[i]);
write(w[i].Onoma:20);write(w[i].Epitheto:20);write(w[i].AM:6)
writeln;
end;
close(f1);close(f2);
end.