#include <bits/stdc++.h>
using namespace std;
bool visited[500][500];
char bar[500][500];
int w, h, n;
int sum;
void dfs(int i, int j) {
  if (i < 0 || j < 0 || i >= h * 2 || j >= w * 2 || visited[i][j] ||
      bar[i][j] == 'X')
    return;
  sum += (bar[i][j] == '.');
  visited[i][j] = 1;
  dfs(i + 1, j);
  dfs(i - 1, j);
  dfs(i, j + 1);
  dfs(i, j - 1);
}
int main() {
  cin >> w >> h >> n;
  for (int i = 0; i < h * 2; i++) {
    for (int j = 0; j < w * 2; j++) {
      if (i % 2 == 1 || j % 2 == 1) {
        bar[i][j] = '#';
      } else {
        bar[i][j] = '.';
      }
    }
  }
  for (int i = 0; i < n; i++) {
    pair<int, int> a, b;
    cin >> a.first >> a.second;
    cin >> b.first >> b.second;
    if (a.first == b.first) {
      for (int j = a.second * 2; j < b.second * 2; j++) {
        if (a.first > 0) bar[j][a.first * 2 - 1] = 'X';
      }
    } else {
      for (int j = a.first * 2; j < b.first * 2; j++) {
        if (a.second > 0) bar[a.second * 2 - 1][j] = 'X';
      }
    }
  }
  vector<int> ans;
  for (int i = 0; i < h * 2; i++) {
    for (int j = 0; j < w * 2; j++) {
      if (!visited[i][j] && bar[i][j] != 'X') {
        sum = 0;
        dfs(i, j);
        ans.push_back(sum);
      }
    }
  }
  sort(ans.begin(), ans.end());
  for (int i : ans) {
    cout << i << " ";
  }
}
