{ NOTE: it is recommended to use this even if you don't understand the following code }

const
    MAXM = 200000;

var
    K, M, N, i : LongInt;
    E, L, R, S : Array[0..MAXM-1] of LongInt;
    X          : Int64;

begin
{
    uncomment the two following lines if you want to read/write from files
    assign(input,  'input.txt');  reset(input);
    assign(output, 'output.txt'); rewrite(output);
}

    ReadLn(N, K, M);

    for i:=0 to M-1 do
        ReadLn(L[i], R[i], S[i], E[i]);

    X := 0;

    { INSERT YOUR CODE HERE }


    WriteLn(X);

end.
