program plakatas;
  const PRF = 'SIENA.s02.IN';
  var a, b, //sienos parametrai
      N, m,    //plakatų kiekis
      x, y, xmin, ymin, xmax, ymax, //plakato koordinatės
      plotas, plakato_pl, //sienos ir plakato plotas
      i, j : longint;
      f: text;
begin
  assign (f, PRF);
  reset (f);
  readln (f, a, b, N);
  plotas := a * b;
  for i := 1 to N do begin
    read (f, m, x, y);
    xmin := x; ymin := y;
    xmax := x; ymax := y;
    for j := 1 to m - 1 do begin
       read (f, x, y);
       if x < xmin then xmin := x;
       if x > xmax then xmax := x;
       if y < ymin then ymin := y;
       if y > ymax then ymax := y;
    end;
    plakato_pl := (xmax - xmin) * (ymax - ymin);
    plotas := plotas - plakato_pl;
  end;
  writeln (plotas);
  readln;
end.