#include <bits/stdc++.h>
using namespace std;
int w, h, n, res[105], resc;
bool a[105][105][4], v[105][105];
int xd[4] = {0, 1, 0, -1};
int yd[4] = {-1, 0, 1, 0};
queue<pair<int, int> > q;
int main() {
  int x1, y1, x2, y2, cnt;
  cin >> w >> h >> n;
  for (int i = 0; i < n; i++) {
    cin >> x1 >> y1 >> x2 >> y2;
    if (x1 == x2)
      for (int j = y1; j < y2; j++) a[x1][j][3] = a[x1 - 1][j][1] = true;
    if (y1 == y2)
      for (int j = x1; j < x2; j++) a[j][y1][0] = a[j][y1 - 1][2] = true;
  }
  for (int i = 0; i < w; i++)
    for (int j = 0; j < h; j++)
      if (!v[i][j]) {
        q.push(make_pair(i, j));
        cnt = 0;
        v[i][j] = true;
        while (!q.empty()) {
          x1 = q.front().first;
          y1 = q.front().second;
          q.pop();
          for (int k = 0; k < 4; k++)
            if (!a[x1][y1][k]) {
              x2 = x1 + xd[k];
              y2 = y1 + yd[k];
              if (x2 < 0 || x2 >= w || y2 < 0 || y2 >= h) continue;
              if (v[x2][y2]) continue;
              q.push(make_pair(x2, y2));
              v[x2][y2] = true;
            }
          cnt++;
        }
        res[resc++] = cnt;
      }
  sort(res, res + resc);
  for (int i = 0; i < resc; i++) cout << res[i] << " ";
  return 0;
}
