#include <bits/stdc++.h>
using namespace std;
int mp[1005][1000];
vector<int> ans;
int sum;
void dfs(int i, int j) {
  sum++;
  mp[i][j] = 0;
  if (mp[i - 1][j] && mp[i - 2][j]) {
    dfs(i - 2, j);
  }
  if (mp[i + 1][j] && mp[i + 2][j]) {
    dfs(i + 2, j);
  }
  if (mp[i][j + 1] && mp[i][j + 2]) {
    dfs(i, j + 2);
  }
  if (mp[i][j - 1] && mp[i][j - 2]) {
    dfs(i, j - 2);
  }
}
int main() {
  int i, n, m, k, w, h, x1, x2, y1, y2, j;
  scanf("%d%d%d", &w, &h, &n);
  for (i = 1; i < 2 * w; i++) {
    for (j = 1; j < 2 * h; j++) {
      mp[i][j] = 1;
    }
  }
  for (i = 1; i <= n; i++) {
    scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
    if (x1 == x2) {
      for (k = y1 + y1; k <= y2 + y2; k++) {
        mp[x1 + x1][k] = 0;
      }
    } else {
      for (k = x1 + x1; k <= x2 + x2; k++) {
        mp[k][y1 + y2] = 0;
      }
    }
  }
  for (i = 1; i <= 2 * w; i += 2) {
    for (j = 1; j <= 2 * h; j += 2) {
      if (mp[i][j] == 1) {
        sum = 0;
        dfs(i, j);
        ans.push_back(sum);
      }
    }
  }
  sort(ans.begin(), ans.end());
  for (i = 0; i < ans.size(); i++) {
    if (i) printf(" ");
    printf("%d", ans[i]);
  }
}
