#include <bits/stdc++.h>
using namespace std;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, 1, 0, -1};
struct LS {
  int x0, y0, x1, y1;
  LS() {}
};
int w, h, n;
LS line[100];
bool seen[100][100];
int dfs(int i, int j) {
  int ret = 1;
  seen[i][j] = true;
  for (int k = 0; k < (int)(4); k++) {
    int ay = i + dy[k], ax = j + dx[k];
    if (ay < 0 || h <= ay || ax < 0 || w <= ax || seen[ay][ax]) continue;
    for (int l = 0; l < (int)(n); l++) {
      if (k == 0) {
        if (line[l].y0 == line[l].y1 && line[l].y1 == ay && line[l].x0 <= ax &&
            ax + 1 <= line[l].x1)
          goto NEXT;
      } else if (k == 1) {
        if (line[l].x0 == line[l].x1 && line[l].x1 == ax && line[l].y0 <= ay &&
            ay + 1 <= line[l].y1)
          goto NEXT;
      } else if (k == 2) {
        if (line[l].y0 == line[l].y1 && line[l].y1 == i && line[l].x0 <= ax &&
            ax + 1 <= line[l].x1)
          goto NEXT;
      } else if (k == 3) {
        if (line[l].x0 == line[l].x1 && line[l].x1 == j && line[l].y0 <= ay &&
            ay + 1 <= line[l].y1)
          goto NEXT;
      }
    }
    ret += dfs(ay, ax);
  NEXT:;
  }
  return ret;
}
int main() {
  while (cin >> w >> h >> n) {
    for (int i = 0; i < (int)(n); i++)
      cin >> line[i].x0 >> line[i].y0 >> line[i].x1 >> line[i].y1;
    memset(seen, 0, sizeof(seen));
    vector<int> areas;
    for (int i = 0; i < (int)(h); i++)
      for (int j = 0; j < (int)(w); j++) {
        if (!seen[i][j]) areas.push_back(dfs(i, j));
      }
    sort(areas.begin(), areas.end());
    for (int i = 0; i < (int)(areas.size()); i++) printf("%d ", areas[i]);
    puts("");
  }
  return 0;
}
