const
  MAXN = 200000;

var
  a: array[1..MAXN] of integer;
  hei, wid, n, i, j, x: integer;

begin
  readln(hei, wid, n);
  for i := 1 to hei do
    a[i] := wid;
  for i := 1 to n do
  begin
    read(x);
    j := 1;
    while (j <= hei) and (a[j] < x) do
      inc(j);
    if (j <= hei) then
    begin
      writeln(j);
      dec(a[j], x);
    end
    else
      writeln(-1);
  end;
end.