#include <bits/stdc++.h>
#define MAX_INT 2147483647
#define MAX_LONG 9223372036854775807ll
#define MAX_ULONG 18446744073709551615ull
#define MAX_DBL 1.7976931348623158e+308
#define EPS 1e-9
const double PI = 2.0*acos(0.0);
#define INF 1000000000
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
// swapped the array limits here as we make sure m < n
int m, n, k, city[1005][30005], x, y, r, b, dis[1005], ans[1000005];
void update_ranges() {
int i, j, r2 = r*r, lim;
city[y][(x-r) >= 1 ? x-r : 1] += b;
if (x+r+1 <= n) city[y][x+r+1] -= b;
// only compute necessary square roots
lim = min(r-1, max(y-1, m-y));
for (i=1, j=0; i<=lim; i++, j++)
dis[j] = (int) sqrt(r2-i*i);
lim = min(m, y+r-1);
for (i=y+1, j=0; i<=lim; i++, j++) {
city[i][(x-dis[j]) >= 1 ? x-dis[j] : 1] += b;
if (x+dis[j]+1 <= n) city[i][x+dis[j]+1] -= b;
}
if ((y+r) <= m) {
city[y+r][x] += b;
if (x < n) city[y+r][x+1] -= b;
}
lim = max(0, y-r+1);
for (i=y-1, j=0; i>=lim; i--, j++) {
city[i][(x-dis[j]) >= 1 ? x-dis[j] : 1] += b;
if (x+dis[j]+1 <= n) city[i][x+dis[j]+1] -= b;
}
if ((y-r) >= 1) {
city[y-r][x] += b;
if (x < n) city[y-r][x+1] -= b;
}
}
int main () {
ios_base::sync_with_stdio(0);
int i, j;
scanf("%d", &m);
scanf("%d", &n);
scanf("%d", &k);
// we swap x and y if m >= n, because this way we get K * min(m,n) operations
// in the update_ranges() function instead of K * m operations
bool swapped = false;
if (m > n) {
swap(m,n);
swapped = true;
}
for (i=0; i<k; i++) {
scanf("%d %d %d %d", &x, &y, &r, &b);
if (swapped) swap(y,x);
update_ranges();
}
for (i=1; i<=m; i++)
for (j=1; j<=n; j++)
ans[city[i][j] += city[i][j-1]]++;
for (i=1000005; ans[i]==0; i--);
printf("%d\n%d\n", i, ans[i]);
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3R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IGo9MDsgaTw9bGltOyBpKyssIGorKykgewogICAgICAgICAgICAgICAgY2l0eVtpXVsoeC1kaXNbal0pID49IDEgPyB4LWRpc1tqXSA6IDFdICs9IGI7CiAgICAgICAgICAgICAgICBpZiAoeCtkaXNbal0rMSA8PSBuKSBjaXR5W2ldW3grZGlzW2pdKzFdIC09IGI7CiAgICAgICAgfQogICAgICAgIGlmICgoeStyKSA8PSBtKSB7CiAgICAgICAgICAgICAgICBjaXR5W3krcl1beF0gKz0gYjsKICAgICAgICAgICAgICAgIGlmICh4IDwgbikgY2l0eVt5K3JdW3grMV0gLT0gYjsKICAgICAgICB9CiAgICAgICAgbGltID0gbWF4KDAsIHktcisxKTsKICAgICAgICBmb3IgKGk9eS0xLCBqPTA7IGk+PWxpbTsgaS0tLCBqKyspIHsKICAgICAgICAgICAgICAgIGNpdHlbaV1bKHgtZGlzW2pdKSA+PSAxID8geC1kaXNbal0gOiAxXSArPSBiOwogICAgICAgICAgICAgICAgaWYgKHgrZGlzW2pdKzEgPD0gbikgY2l0eVtpXVt4K2Rpc1tqXSsxXSAtPSBiOwogICAgICAgIH0KICAgICAgICBpZiAoKHktcikgPj0gMSkgewogICAgICAgICAgICAgICAgY2l0eVt5LXJdW3hdICs9IGI7CiAgICAgICAgICAgICAgICBpZiAoeCA8IG4pIGNpdHlbeS1yXVt4KzFdIC09IGI7CiAgICAgICAgfQp9CiAKaW50IG1haW4gKCkgewogICAgICAgIGlvc19iYXNlOjpzeW5jX3dpdGhfc3RkaW8oMCk7CiAgICAgICAgaW50IGksIGo7CiAgICAgICAKICAgICAgICBzY2FuZigiJWQiLCAmbSk7CiAgICAgICAgc2NhbmYoIiVkIiwgJm4pOwogICAgICAgIHNjYW5mKCIlZCIsICZrKTsKCiAgICAgICAgLy8gd2Ugc3dhcCB4IGFuZCB5IGlmIG0gPj0gbiwgYmVjYXVzZSB0aGlzIHdheSB3ZSBnZXQgSyAqIG1pbihtLG4pIG9wZXJhdGlvbnMgCiAgICAgICAgLy8gaW4gdGhlIHVwZGF0ZV9yYW5nZXMoKSBmdW5jdGlvbiBpbnN0ZWFkIG9mIEsgKiBtIG9wZXJhdGlvbnMKICAgICAgICBib29sIHN3YXBwZWQgPSBmYWxzZTsKICAgICAgICBpZiAobSA+IG4pIHsKICAgICAgICAJc3dhcChtLG4pOwogICAgICAgIAlzd2FwcGVkID0gdHJ1ZTsKICAgICAgICB9CiAgICAgICAKICAgICAgICBmb3IgKGk9MDsgaTxrOyBpKyspIHsKICAgICAgICAgICAgICAgIHNjYW5mKCIlZCAlZCAlZCAlZCIsICZ4LCAmeSwgJnIsICZiKTsKICAgICAgICAgICAgICAgIGlmIChzd2FwcGVkKSBzd2FwKHkseCk7CiAgICAgICAgICAgICAgICB1cGRhdGVfcmFuZ2VzKCk7CiAgICAgICAgfQogICAgICAgCiAgICAgICAgZm9yIChpPTE7IGk8PW07IGkrKykKICAgICAgICAgICAgICAgIGZvciAoaj0xOyBqPD1uOyBqKyspCiAgICAgICAgICAgICAgICAgICAgICAgIGFuc1tjaXR5W2ldW2pdICs9IGNpdHlbaV1bai0xXV0rKzsKICAgICAgIAogICAgICAgIGZvciAoaT0xMDAwMDA1OyBhbnNbaV09PTA7IGktLSk7CiAgICAgICAKICAgICAgICBwcmludGYoIiVkXG4lZFxuIiwgaSwgYW5zW2ldKTsKICAgICAgIAogICAgICAgIHJldHVybiAwOwp9