#include <bits/stdc++.h>
using namespace std;
const long long int maxN = 1e5 + 100;
const long long int maxM = 13 + 100;
const long long int mod = 1e9 + 7;
const long long int hmod = 1e16 + 7;
const long double PI = 3.141592653;
const long double eps = 1e-8;
const long long int D = 1379;
const long long int INF = 1e18 + 20;
const long long int Inf = 1e9 + 140;
bool mrk[maxM][maxM], dp[2][maxM][maxM][maxM];
vector<long long int> ans;
long long int n, h, w;
long long int dx[4] = {1, -1, 0, 0};
long long int dy[4] = {0, 0, 1, -1};
void dfs(long long int i, long long int j) {
  if (mrk[i][j]) return;
  ans.back()++;
  mrk[i][j] = true;
  if (i - 1 >= 0 && !dp[0][i][j][j + 1]) dfs(i - 1, j);
  if (i + 1 < w && !dp[0][i + 1][j][j + 1]) dfs(i + 1, j);
  if (j - 1 >= 0 && !dp[1][j][i][i + 1]) dfs(i, j - 1);
  if (j + 1 < h && !dp[1][j + 1][i][i + 1]) dfs(i, j + 1);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> w >> h >> n;
  for (long long int i = 1; i <= n; i++) {
    long long int x1, x2, y1, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    if (x1 - x2)
      for (long long int j = x1; j <= x2 - 1; j++) dp[1][y1][j][j + 1] = true;
    else
      for (long long int j = y1; j <= y2 - 1; j++) dp[0][x1][j][j + 1] = true;
  }
  for (long long int i = 0; i <= w - 1; i++)
    for (long long int j = 0; j <= h - 1; j++)
      if (!mrk[i][j]) {
        ans.push_back(0);
        dfs(i, j);
      }
  sort(ans.begin(), ans.end());
  for (long long int i = 0; i <= ((int)(ans).size()) - 1; i++)
    cout << ans[i] << ' ';
}
