#include <bits/stdc++.h>
using namespace std;
int a[105][105] = {0}, b[105][105] = {0}, w, h, xs, ys, xf, yf, n, ans[10005],
    s = 0;
void dfs(int x, int y) {
  if (b[x][y]) return;
  ans[s]++;
  b[x][y] = 1;
  if (!(a[x][y] & 1))
    if (x - 1 >= 0) dfs(x - 1, y);
  if (!(a[x][y] & 2))
    if (y + 1 < h) dfs(x, y + 1);
  if (!(a[x][y] & 4))
    if (x + 1 < w) dfs(x + 1, y);
  if (!(a[x][y] & 8))
    if (y - 1 >= 0) dfs(x, y - 1);
}
int main() {
  cin >> w >> h >> n;
  for (int i = 1; i <= n; i++) {
    cin >> xs >> ys >> xf >> yf;
    if (xs == xf) {
      if (ys > yf) swap(ys, yf);
      for (int j = ys; j < yf; j++) a[xs][j] += 1, a[xs - 1][j] += 4;
    }
    if (ys == yf) {
      if (xs > xf) swap(xs, xf);
      for (int j = xs; j < xf; j++) a[j][ys] += 8, a[j][ys - 1] += 2;
    }
  }
  for (int i = 0; i < w; i++)
    for (int j = 0; j < h; j++) {
      if (b[i][j] == 0) {
        s++;
        dfs(i, j);
      }
    }
  sort(ans + 1, ans + s + 1);
  for (int i = 1; i <= s; i++) cout << ans[i] << " ";
  return 0;
}
