#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define Rep(i,a,n)for(int i=(int)(a);i<(int)(n);i++)
#define rep(i,n)Rep(i,0,n)
typedef long long ll;
typedef long double ld;
#define M(x,y) ((x)>(y)?(x):(y))
#define m(x,y) ((x)<(y)?(x):(y))
#define N 200001

int main() {
	int n, m, q, a[51], b[51], c[51], d[51], sum=0;
	scanf("%d %d %d", &n, &m, &q);
	rep(i, q)scanf("%d %d %d %d", &a[i], &b[i], &c[i], &d[i]);
	rep(i, q)sum += d[i];
	printf("%d", sum);
}