Program qwer;
uses crt;
var a : array[1..1000,1..1000] of integer;
i,j,x,y,min,max : integer;
begin
read(x,y);
min := 100;
max := 0;
for i := 1 to x do
for j:= 1 to y do
begin
a[i,j] := random(101);
if a[i,j] < min then min := a[i,j];
if a[i,j] > max then max := a[i,j];
end;
writeln(min);
write(max);
end.