uses
  SysUtils;

const
  maxn = 20;
  maxt = 24 * 60;

var
  x, y, a, b, n, i, j, k : integer;
  s : string;
  time : array[0..maxt - 1] of integer;
  ans1, ans2 : array[1..maxn] of integer;
  nans : integer;
  en : integer;

begin
  reset(input, 'cat.in');
  rewrite(output, 'cat.out');
  read(a, b);
  readln(n);
  a := a * 60;
  b := b * 60;
  for i := 1 to n do begin
    readln(s);
    x := StrToInt(copy(s, 1, 2)) * 60 + StrToInt(copy(s, 4, 2));
    y := StrToInt(copy(s, 7, 2)) * 60 + StrToInt(copy(s, 10, 2));
    if (x < y) then begin
      for j := x to y do begin
        time[j] := 1;
      end;
    end else begin
      for j := x to maxt - 1 do begin
        time[j] := 1;
      end;
      for j := 0 to y do begin
        time[j] := 1;
      end;
    end;
  end;

  i := 0;
  while (time[i] <> 1) do begin
    i := i + 1;
  end;
  en := i;
  i := i + 1;
  while (i <> en) do begin
    while (i <> en) and (time[i] = 1) do begin
      i := (i + 1) mod maxt;
    end;
    if (i = en) then break;
    j := (i + 1) mod maxt;
    while (j <> en) and (time[j] = 0) do begin
      j := (j + 1) mod maxt;
    end;
    if ((j - i + maxt) mod maxt >= a) then begin
      k := i;
      while (k <> j) do begin
        time[k] := 2;
        k := (k + 1) mod maxt;
      end;
    end;
    i := j;
  end;

  i := 0;
  while (i < maxt) do begin
    while (i < maxt) and (time[i] = 2) do begin
      i := i + 1;
    end;
    j := i + 1;
    while (j < maxt) and (time[j] <> 2) do begin
      j := j + 1;
    end;
    if (j - i > b) then begin
      writeln('No');
      halt;
    end;
    i := j;
  end;

  i := 0;
  while (time[i] <> 2) do begin
    i := i + 1;
  end;
  j := maxt - 1;
  while (time[j] <> 2) do begin
    j := j - 1;
  end;
  if (i - j + maxt - 1 > b) then begin
    writeln('No');
    halt;
  end;

  en := 0;
  i := 0;
  if (time[0] = 2) then begin
    i := maxt - 1;
    while (time[i] = 2) do begin
      i := i - 1;
    end;
    en := i;
    i := (i + 1) mod maxt;
  end else begin
    while (time[i] <> 2) do begin
      i := i + 1;
    end;
  end;

  nans := 0;
  while (i <> en) do begin
    while (i <> en) and (time[i] <> 2) do begin
      i := (i + 1) mod maxt;
    end;
    if (i = en) then begin
      break;
    end;
    j := (i + 1) mod maxt;
    while (j <> en) and (time[j] = 2) do begin
      j := (j + 1) mod maxt;
    end;
    nans := nans + 1;
    ans1[nans] := i;
    ans2[nans] := j - 1;
    i := j;
  end;

  writeln('Yes');
  writeln(nans);
  for i := 1 to nans do begin
    writeln(format('%.2d:%.2d-%.2d:%.2d', [ans1[i] div 60, ans1[i] mod 60, ans2[i] div 60, ans2[i] mod 60]));
  end;
end.