program task_d; {$APPTYPE CONSOLE} uses SysUtils; var n,m,i,j,ans,max:integer; a:array[0..1001,0..1001] of longint; s:array[1..1000] of boolean; f:text; function fmax(a,b:longint):longint; begin if (a>=b) then fmax:=a else fmax:=b; end; procedure pr(c:integer); var i:integer; begin if (c=(n+1)) then begin max:=fmax(ans,max); end else begin for i:=1 to n do begin if (s[i]) then begin ans:=ans+a[c,i]; s[i]:=false; pr(c+1); s[i]:=true; ans:=ans-a[c,i]; end; end; end; end; begin assign(f,'legacy.in'); reset(f); readln(f,n,m); for i:=1 to n do begin for j:=1 to n do read(f,a[i,j]); readln(f); end; close(f); max:=0; ans:=0; fillchar(s,sizeof(s),true); pr(1); assign(f,'legacy.out'); rewrite(f); writeln(f,max); close(f); { TODO -oUser -cConsole Main : Insert code here } end.