#include using namespace std; #include using namespace atcoder; template inline bool chmax(T &a, T b) { return ((a < b) ? (a = b, true) : (false)); } template inline bool chmin(T &a, T b) { return ((a > b) ? (a = b, true) : (false)); } #define rep(i, n) for (int i = 0; i < (long long)(n); i++) #define rep2(i, m ,n) for (int i = (m); i < (long long)(n); i++) #define REP(i, n) for (long long i = 1; i < (long long)(n); i++) typedef long long ll; #define updiv(N,X) (N + X - 1) / X #define l(n) n.begin(),n.end() #define YesNo(Q) Q==1?cout<<"Yes":cout<<"No" using P = pair; using mint = modint; const int MOD = 998244353LL; ll solve(vector w){ set st; vector> v; rep(i,w.size()){v.push_back(pair(w[i],i));} sort(l(v)); st.insert(-1); int n = w.size(); st.insert(n); ll ans = 0; rep(i,n){ auto t = st.lower_bound(v[i].second); auto k = t;k--; ans += ((ll)(*t) - (ll)(*k) - 1) * v[i].first; st.insert(v[i].second); } return ans; } int main(){ ll h,w,n;cin>>h>>w>>n; vector> v(h,vector(w,0)); rep(i,n){ ll a,b;cin>>a>>b;a--;b--; v[a][b] = 1; } vector> t(h,vector(w,0)); rep(i,h){ ll now = 0; rep(j,w){now++;if(v[i][w-j-1]==1){now = 0;}t[i][w-j-1] = now;} } ll ans = 0; rep(i,w){vector w(h); rep(j,h){w[j] = t[j][i];} // rep(j,h){cout << w[j] << " ";}cout<