{
TASK:SIENAV
LANG:PASCAL
}
program siena;
var f: text;
    p, a, n, plotas,
    minx, miny, maxx, maxy, m,
    x, y, i, j: longint;
begin
    assign(f, 'SIENA.IN');
    reset(f);
    readln(f, p, a);
    readln(f, n);
    plotas := p*a;
    for i := 1 to n do begin
        read(f, m, minx, miny);
        maxx := minx;
        maxy := miny;
        for j := 2 to m do begin
            read(f, x, y);
            if (minx > x) then minx := x;
            if (maxx < x) then maxx := x;
            if (miny > y) then miny := y;
            if (maxy < y) then maxy := y;
        end;
        plotas := plotas - (maxx-minx) * (maxy-miny);
    end;
    close(f);
    assign(f, 'SIENA.OUT');
    rewrite(f);
    writeln(f, plotas);
    close(f);
end.
