/** * author: otera **/ #include using namespace std; #define int long long typedef long long ll; typedef long double ld; const int inf=1e9+7; const ll INF=1LL<<60; #define rep(i, n) for(int i = 0; i < n; ++ i) #define per(i,n) for(int i=n-1;i>=0;i--) #define Rep(i,sta,n) for(int i=sta;i P; typedef pair LP; #define fr first #define sc second #define all(c) c.begin(),c.end() template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } template struct SegmentTree{ private: int n; T E; vector node; inline void updatef(T& x,T& y){ //x = y; // x += y; //x = max(x,y); x = min(x,y); } inline T queryf(T& x,T& y){ //return min(x,y); return x+y; //return max(x,y); } public: SegmentTree(int sz,T E_):E(E_){ n=1; while(n& A,T E_):E(E_){ int sz=A.size(); n=1; while(n=0;--i){ node[i]=queryf(node[2*i+1], node[2*i+2]); } } void update(int k,T x){ k+=n-1; updatef(node[k],x); while(k>0){ k=(k-1)/2; node[k]=queryf(node[2*k+1], node[2*k+2]); } } //[a,b)での値を返す T get(int a,int b,int k=0,int l=0,int r=-1){ if(r<0)r=n; if(r<=a||b<=l)return E; if(a<=l&&r<=b)return node[k]; T xl=get(a,b,2*k+1,l,(l+r)/2); T xr=get(a,b,2*k+2,(l+r)/2,r); return queryf(xl, xr); } }; void solve() { int h, w; cin >> h >> w; int q; cin >> q; vector y(q), x(q); rep(i, q) { cin >> y[i] >> x[i]; -- y[i], -- x[i]; } auto comx = x; sort(all(comx)); comx.erase(unique(all(comx)), comx.end()); int sz = (int)comx.size(); ll offset = (w - sz) * h; vector vec(sz, h); SegmentTree seg(vec, 0); rep(i, q) { x[i] = lower_bound(all(comx), x[i]) - comx.begin(); seg.update(x[i], y[i]); cout << offset + seg.get(0, sz) << "\n"; } } signed main() { ios::sync_with_stdio(false); cin.tie(0); //cout << fixed << setprecision(20); //int t; cin >> t; rep(i, t)solve(); solve(); return 0; }