#include <bits/stdc++.h>
using namespace std;
using namespace rel_ops;
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};
const int inf = 1010101010;
const double PI = 4 * atan(1);
const int _right = 0;
const int _bottom = 1;
const int _left = 2;
const int _top = 3;
struct CF31D {
  vector<vector<vector<bool> > > adj;
  vector<vector<int> > compno;
  void dfs(int y, int x, int num) {
    compno[y][x] = num;
    vector<bool> const& v = adj[y][x];
    if (v[_right] && compno[y][x + 1] == -1) dfs(y, x + 1, num);
    if (v[_left] && compno[y][x - 1] == -1) dfs(y, x - 1, num);
    if (v[_top] && compno[y + 1][x] == -1) dfs(y + 1, x, num);
    if (v[_bottom] && compno[y - 1][x] == -1) dfs(y - 1, x, num);
  }
  void solve(int w, int h, int n,
             vector<pair<pair<int, int>, pair<int, int> > >& breaks) {
    adj = vector<vector<vector<bool> > >(
        h, vector<vector<bool> >(w, vector<bool>(4)));
    for (int i = 0; i < (h); i++)
      for (int j = 0; j < (w); j++) {
        if (j) adj[i][j][_left] = true;
        if (j != w - 1) adj[i][j][_right] = true;
        if (i) adj[i][j][_bottom] = true;
        if (i != h - 1) adj[i][j][_top] = true;
      }
    for (typeof((breaks).begin()) it = (breaks).begin(); it != (breaks).end();
         ++it) {
      pair<pair<int, int>, pair<int, int> >& p = *it;
      int xi1 = p.first.first, yi1 = p.first.second, xi2 = p.second.first,
          yi2 = p.second.second;
      if (xi1 == xi2) {
        for (int yy = yi1; yy < yi2; yy++) {
          adj[yy][xi1][_left] = false;
          adj[yy][xi1 - 1][_right] = false;
        }
      } else {
        for (int xx = xi1; xx < xi2; xx++) {
          adj[yi1][xx][_bottom] = false;
          adj[yi1 - 1][xx][_top] = false;
        }
      }
    }
    compno = vector<vector<int> >(h, vector<int>(w, -1));
    int num = 0;
    for (int i = 0; i < (h); i++)
      for (int j = 0; j < (w); j++) {
        if (compno[i][j] == -1) {
          dfs(i, j, num);
          num++;
        }
      }
    vector<int> sz(num);
    for (int i = 0; i < (h); i++)
      for (int j = 0; j < (w); j++) sz[compno[i][j]]++;
    sort((sz).begin(), (sz).end());
    for (typeof((sz).begin()) it = (sz).begin(); it != (sz).end(); ++it)
      cout << *it << " ";
    cout << endl;
  }
};
int main() {
  int w, h, n;
  cin >> w >> h >> n;
  vector<pair<pair<int, int>, pair<int, int> > > bla(n);
  for (int it = 0; it < (n); it++) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    bla[it] = make_pair(make_pair(a, b), make_pair(c, d));
  }
  CF31D x;
  x.solve(w, h, n, bla);
}
