{
TASK:skok
LANG:Pascal
}
program skok;
var n, m, pl   : word;
    i, q       : word;
    j, h       : array[0..200] of word;
    b          : array[0..200000] of word;
    br, apples : word;
    place      : word;

begin

read(n); readln(m);
for i := 1 to m do
 begin
  read(j[i]);
  h[i] := 1;
 end;

for i := 0 to n do
 read(b[i]);

h[0] := 0;
apples := 0;

while h[0] = 0 do
 begin
 i := m;
 if h[i] = m
  then
   begin
    while h[i] = m do i := i - 1;
    h[i] := h[i] + 1;
    for q := i+1 to m do h[q] := 1;
   end
  else
   begin
    h[i] := h[i] + 1;
    pl := 0; br := b[0];
    q := 1;
    while pl+ j[h[q]] <= n do
     begin
      pl := pl + j[h[q]] + 1;
      br := br + b[pl];
      q := q + 1;
     end;
    if br > apples
     then
      begin
       apples := br;
       place := pl;
      end;
   end;
 end;
write(apples); writeln(place-1);
end.
