#include <bits/stdc++.h>
using namespace std;
int X, Y;
int n;
int cnt;
bool used[1000][1000];
bool edge[1000][1000][4];
const int DX[] = {1, 0, -1, 0}, DY[] = {0, 1, 0, -1};
vector<int> ans;
void dfs(int x, int y) {
  if (x < 0 || x >= X || y < 0 || y >= Y || used[x][y]) return;
  used[x][y] = true;
  cnt++;
  for (int i = 0; i < 4; i++) {
    if (!edge[x][y][i]) {
      dfs(x + DX[i], y + DY[i]);
    }
  }
}
int main() {
  scanf("%d%d%d", &X, &Y, &n);
  for (int i = 1; i <= n; i++) {
    int x1, y1, x2, y2;
    scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
    if (x1 == x2) {
      for (int j = y1; j < y2; j++) {
        edge[x1 - 1][j][0] = true;
        edge[x1][j][2] = true;
      }
    } else if (y1 == y2) {
      for (int j = x1; j < x2; j++) {
        edge[j][y1 - 1][1] = true;
        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++) printf("%d ", ans[i]);
  puts("");
  return 0;
}
