#include <bits/stdc++.h>
using namespace std;
int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, -1, 0, 1};
int x, y, t1, t2, sum;
int flag1[105][105], flag2[105];
int mp1[100005], mp2[100005];
bool ok[105][105][4];
int main() {
  int n, m, k, x1, x2, y1, y2;
  cin >> n >> m >> k;
  for (int ii = 0; ii < k; ii++) {
    cin >> x1 >> y1 >> x2 >> y2;
    if (x1 == x2) {
      for (int i = y1; i < y2; i++) {
        ok[x1][i][0] = true;
        ok[x1 - 1][i][2] = true;
      }
    } else {
      for (int i = x1; i < x2; i++) {
        ok[i][y1][1] = true;
        ok[i][y1 - 1][3] = true;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    int ii = 0;
    for (int j = 0; j < m; j++) {
      if (flag1[i][j] == 0) {
        ii++;
        flag1[i][j] = ii;
        t1 = 0;
        t2 = 1;
        mp1[t1] = i;
        mp2[t1] = j;
        while (t1 < t2) {
          x = mp1[t1];
          y = mp2[t1++];
          for (k = 0; k < 4; k++) {
            if (ok[x][y][k] == false) {
              int p1 = x + dx[k];
              int p2 = y + dy[k];
              if (p1 >= 0 && p1 < n && p2 >= 0 && p2 < m &&
                  flag1[p1][p2] == 0) {
                flag1[p1][p2] = ii;
                mp1[t2] = p1;
                mp2[t2++] = p2;
              }
            }
          }
        }
        flag2[sum++] = t2;
      }
    }
  }
  sort(flag2, flag2 + sum);
  for (int i = 0; i < sum; i++) cout << flag2[i] << " ";
  return 0;
}
