#include #include #include #include #include #include #include #include #include #include using ll = long long; using namespace std; int main(){ int w, h, n, ans = 0; cin >> w >> h >> n; int suit_n = w, num_n = h; vector suit(w), num(h); for (int i = 0; i < n; i++){ int s, k; cin >> s >> k; if (suit[s-1]){ if (!num[k-1]){ ans--; num[k]++; num_n--; ans += suit_n; } } else { if (num[k-1]){ ans--; suit[s-1]++; suit_n--; ans += num_n; } else { suit[s-1]++; num[k-1]++; num_n--; suit_n--; ans += (num_n + suit_n); } } } cout << ans << endl; }