var
t,i,j,k,l,max,x,n,m:longint;
c,a: array [1..1000] of longint;
begin
     assign(input,'alibaba.in'); reset(input);
     read(t);
     for i:=1 to t do
     begin
            n:=0;
            m:=0;
            max:=0;
            j:=0;
            k:=0;
            x:=0;
          l:=1;
          for j:=1 to 1000 do begin a[j]:=0; c[j]:=0; end;
          read(n,m);
          for j:=1 to n do
          begin
               read(c[j]);
               if c[j]>0 then
               begin
                    a[l]:=c[j];
                    inc(l);
               end;
          end;
          for j:=1 to l-1 do
          begin
               for k:=j+1 to l do
               begin
                    if a[j]<a[k] then
                    begin
                         x:=a[j]; a[j]:=a[k]; a[k]:=x;
                    end;
               end;
          end;
          for j:=1 to M do max:=max+a[j];
          writeln(max);
     end;
end.

