#include <bits/stdc++.h>
using namespace std;
const int N = 111, dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
bool a[N][N][4];
int w, h, n, c[N][N], now;
vector<int> ans;
int dfs(int x, int y) {
  c[x][y] = now;
  int res = 1;
  for (int d = 0; d < 4; ++d)
    if (a[x][y][d]) {
      int nx = x + dx[d], ny = y + dy[d];
      if (!c[nx][ny]) res += dfs(nx, ny);
    }
  return res;
}
int main() {
  scanf("%d%d%d", &w, &h, &n);
  for (int i = 0; i < w; ++i) {
    for (int j = 0; j < h; ++j) {
      for (int d = 0; d < 4; ++d) {
        int ni = i + dx[d], nj = j + dy[d];
        a[i][j][d] = ni >= 0 && ni < w && nj >= 0 && nj < h;
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    int x1, x2, y1, y2;
    scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
    if (x1 == x2) {
      for (int y = min(y1, y2); y < max(y1, y2); ++y) {
        a[x1 - 1][y][1] = false;
        a[x1][y][3] = false;
      }
    } else {
      for (int x = min(x1, x2); x < max(x1, x2); ++x) {
        a[x][y1 - 1][0] = false;
        a[x][y1][2] = false;
      }
    }
  }
  for (int i = 0; i < w; ++i) {
    for (int j = 0; j < h; ++j) {
      if (!c[i][j]) {
        ++now;
        ans.push_back(dfs(i, j));
      }
    }
  }
  sort(ans.begin(), ans.end());
  int m = ans.size();
  for (int i = 0; i < m; ++i) {
    printf("%d%s", ans[i], i + 1 == m ? "\n" : " ");
  }
}
