program PascalGuru;
type data=record
den:integer;
mes:integer;
god:integer;
end;
var i,n,code,mingod:integer;
m_d,m_m,m_g:integer;
f:text;
s,x:string;
A:array [1..50] of data;
{----------------------------}
begin
assign(f,'fail.txt'); reset(f);
i:=0;
while not eof(f) do
begin
readln(f,s);
x:=copy(s,1,pos('.',s)-1 );
delete(s,1,pos('.',s) );
val(x,n,code);
inc(i);
A[i].den:=n;
x:=copy(s,1,pos('.',s)-1 );
delete(s,1,pos('.',s) );
val(x,n,code);
A[i].mes:=n;
val(s,n,code);
A[i].god:=n;
end;
n:=i;
mingod:=A[1].god;
for i:=2 to n do
if A[i].god<mingod then mingod:=A[i].god;
writeln('Minimalinyi god: ',mingod);
writeln('Vse vessennie daty:');
for i:=1 to n do
if (A[i].mes>2) and (A[i].mes<6) then
writeln(A[i].den,'.',A[i].mes,'.',A[i].god);
m_g:=A[1].god;
for i:=2 to n do
if m_g<A[i].god then m_g:=A[i].god;
m_m:=A[1].mes;
for i:=2 to n do
if A[i].god=m_g then
if m_m<A[i].mes then m_m:=A[i].mes;
m_d:=A[1].den;
for i:=2 to n do
if A[i].god=m_g then
if A[i].mes=m_m then
if m_d<A[i].den then m_d:=A[i].den;
writeln('MAX data:');
writeln(m_d,'.',m_m,'.',m_g);
close(f);
readln;
end.