{$APPTYPE CONSOLE}

uses
  Math, SysUtils;

var
  f: TextFile;
  bmp: array of array of Byte;
  x, x1, y, y1, xc, yc, r, c, Xsize, Ysize, N, i, xl, xr: Integer;
  t: Double;
begin
  t := Now;
  Read(Xsize, Ysize, N); SetLength(bmp, Ysize, Xsize);
  for i := 1 to N do begin
    Read(xc, yc, r, c);
    for y := yc - r to yc do begin
      x1 := Trunc(Sqrt(Sqr(r) - Sqr(y - yc))) + 1;
      while Sqr(x1) + Sqr(y - yc) > Sqr(r) do Dec(x1);
      xl := Max(xc - x1, 0); xr := Min(xc + x1, Xsize - 1);
      if y >=0 then
        FillChar(bmp[y, xl], xr - xl + 1, c);
      y1 :=  yc + yc - y;
      if (0 < y1) and (y1 < YSize) then
        FillChar(bmp[y1, xl], xr - xl + 1, c);
    end;
  end;
  
//  Writeln(FormatDateTime('nn:ss.zzz', Now - t));
  for y := 0 to Ysize - 1 do begin
    for x := 0 to Xsize - 1 do begin
      Write(bmp[y, x]);
    end;
    Writeln();
  end;
end.
