{
TASK:skok
LANG:Pascal
}

type
  Masiv = array[0..200000] of LongInt;

var
  a: Masiv;
  jump: array[1..200] of Integer;
  acc: array[0..200000] of Boolean;
  n,m: LongInt;
  i,j: LongInt;
  temp: LongInt;
  max,ans: LongInt;

procedure input;
begin
  readln(n,m);
  for i:= 1 to m do
    read(jump[i]);
  readln;
  for i:= 0 to n do
    read(a[i]);
end;

procedure solve;
begin
  max:= 0; ans:= 0;
  acc[0]:= true;
  for i:= 1 to n do
    acc[i]:= false;

  for i:= 1 to n do
  begin
    temp:= a[i];
    for j:= 1 to m do
    begin
      if ((i - jump[j]) >= 0) and (acc[i - jump[j]]) then
        if a[i] + a[i - jump[j]] > temp then
          temp:= a[i] + a[i - jump[j]];
    end;

    if temp > a[i] then
    begin
      a[i]:= temp;
      acc[i]:= true;
    end;

    if a[i] > max then
    begin
      max:= a[i];
      ans:= i;
    end;
  end;
end;

procedure output;
begin
  writeln(max,' ',ans);
end;

begin
  input;
  solve;
  output;
end.
