program e;

uses
sysutils;

var
  km: array [1.. 10000] of integer;
  nn, mm: longint;
  m, n, k: integer;
  i, p, code: longint;
  ps: string;
  bool, b1: boolean;

procedure sug(bool: boolean; day: integer);
begin
  if bool then
    writeln('SELL ON DAY ' + inttostr(day))
  else
    writeln('BUY ON DAY ' + inttostr(day))
end;

begin
  assign(input, 'easy.in'); reset(input);
  assign(output, 'easy.out'); rewrite(output);
  readln(m, n, k);
  nn := 0; mm := 0; bool := false;
  for i := 1 to k do
  begin
    readln(ps);
    delete(ps, length(ps)-2, 1);
    val(ps, p, code);
    km[i] := p;
    inc(nn, km[i]); inc(mm, km[i]);
    if i > n then
      dec(nn, km[i-n]);
    if i > m then
      dec(mm, km[i-m]);
    b1 := nn/n > mm/m;
    if i = n then
    begin
      bool :=  b1;
      sug(bool, i);
    end;

    if (i > n) and (b1 <> bool) then
    begin
      bool :=  b1;
      sug(bool, i);
    end;
  end;
  close(input);
  close(output);
end.
