перевести код на Python const MAX = 38;
var n,x,y,i,j : integer;
var m : array [1..MAX, 1..MAX] of integer;
var maxH : integer;
procedure spojuj(x,y,hloubka : integer);
var i,j : integer;
begin
if hloubka > maxH then maxH := hloubka;
for i:=1 to MAX do
if m[y, i] > 0 then
begin
dec(m[y,i]);
spojuj(y, i, hloubka +1);
spojuj(i, y, hloubka +1);
inc(m[y,i]);
end
else if m[i, y] > 0 then
begin
dec(m[i,y]);
spojuj(i, y, hloubka +1);
spojuj(y, i, hloubka +1);
inc(m[i,y]);
end;
end;
begin
maxH := 0;
for i:=1 to MAX do
for j:=1 to MAX do
m[i,j] := 0;
read(n);
for i:=1 to n do
begin
read(x,y);
inc(m[x,y]);
end;
for i:=1 to MAX do
for j:=1 to MAX do
if m[i,j] > 0 then
begin
dec(m[i,j]);
spojuj(i,j,1);
spojuj(j,i,1);
inc(m[i,j]);
end;
write(maxH);
end.