{Woburn Challenge VII}
{Program BATTLE}

function min(a, b: longint): longint;
begin
     if a>b then min:=b else min:=a
end;


var inf, outf: text;
    n, result, monk, tasks, i, j, k: longint;
    list: array[1..101] of integer;

    time: array[0..100, 0..100] of integer;
    best: array[0..100, 0..100] of longint;

begin
     assign(inf, 'battle.in');
     assign(outf, 'battle.out');
     reset(inf);
     rewrite(outf);
     readln(inf, n);
     while n>0 do begin
           dec(n);
           readln(inf, monk, tasks);
           for i:=1 to monk do for j:=1 to tasks do read(inf, time[i, j]);
           for i:=1 to monk do best[i, 0]:=0;
           for i:=1 to tasks do begin
               for j:=1 to monk do begin
                   best[j, i]:=2000000000;
                   for k:=1 to monk do if k<>j
                   then best[j, i]:=min(best[j, i], time[j, i]+best[k, i-1]);
               end;
           end;
           result:=2000000000;
           for i:=1 to monk do result:=min(result, best[i, tasks]);

           writeln(outf, result);

     end;

     close(inf);
     close(outf);
end.


Downloader failed!
Response object
006~ASP 0159~Buffering Off~Buffering must be on.