#include <bits/stdc++.h>
using namespace std;
void solutionD();
int main() {
  ios_base::sync_with_stdio(false);
  solutionD();
  return EXIT_SUCCESS;
}
long long w, h, n, x[128][2], y[128][2];
long long u[128][128];
bool intersect(long long x1, long long y1, long long x2, long long y2) {
  if (x1 > x2) swap(x1, x2);
  if (y1 > y2) swap(y1, y2);
  if (x1 == x2) {
    for (long long i = 0; i < n; ++i) {
      if (y[i][0] != y[i][1]) continue;
      if (y[i][0] != y2) continue;
      if (x[i][0] <= x1 && x[i][1] > x1) return true;
    }
    return false;
  } else {
    for (long long i = 0; i < n; ++i) {
      if (x[i][0] != x[i][1]) continue;
      if (x[i][0] != x2) continue;
      if (y[i][0] <= y1 && y[i][1] > y1) return true;
    }
    return false;
  }
}
long long dfs(long long px, long long py) {
  long long cnt = 1;
  u[px][py] = 1;
  for (long long i = -1; i <= 1; ++i)
    for (long long j = -1; j <= 1; ++j) {
      if (abs(i) == abs(j)) continue;
      long long nx = px + i, ny = py + j;
      if (nx < 0 || ny < 0 || nx >= w || ny >= h) continue;
      if (u[nx][ny]) continue;
      if (intersect(px, py, nx, ny)) continue;
      cnt += dfs(nx, ny);
    }
  return cnt;
}
void solve() {
  memset(u, 0, sizeof(long long) * 128 * 128);
  vector<long long> ans;
  for (long long i = 0; i < w; ++i)
    for (long long j = 0; j < h; ++j)
      if (!u[i][j]) ans.push_back(dfs(i, j));
  sort(ans.begin(), ans.end());
  for (long long i : ans) cout << i << " ";
  cout << endl;
}
void solutionD() {
  for (; cin >> w >> h >> n;) {
    for (long long i = 0; i < n; ++i) {
      for (long long j = 0; j < 2; ++j) cin >> x[i][j] >> y[i][j];
      if (x[i][0] > x[i][1]) swap(x[i][0], x[i][1]);
      if (y[i][0] > y[i][1]) swap(y[i][0], y[i][1]);
    }
    solve();
  }
}
