#include <bits/stdc++.h>
using namespace std;
bool edge[111][111][10];
int cnt;
vector<int> ans;
bool used[111][111];
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
int x, y, n;
void dfs(int i, int j) {
  if (i < 0 || i >= x || j < 0 || j >= y || used[i][j]) return;
  used[i][j] = true;
  cnt++;
  for (int k = 0; k < 4; k++)
    if (!edge[i][j][k]) dfs(i + dx[k], j + dy[k]);
}
int main() {
  cin >> x >> y >> n;
  for (int i = 0; i < n; i++) {
    int x1, x2, y1, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    if (x1 == x2)
      for (int j = y1; j < y2; j++) edge[x1 - 1][j][0] = edge[x1][j][1] = true;
    if (y1 == y2)
      for (int j = x1; j < x2; j++) edge[j][y1 - 1][2] = edge[j][y1][3] = true;
  }
  for (int i = 0; i < x; i++)
    for (int j = 0; j < y; j++)
      if (!used[i][j]) {
        cnt = 0;
        dfs(i, j);
        ans.push_back(cnt);
      }
  sort(ans.begin(), ans.end());
  for (int i = 0; i < ans.size(); i++) cout << ans[i] << " ";
  cout << endl;
  return 0;
}
