#include using namespace std; #define ALL(x) begin(x),end(x) #define rep(i,n) for(int i=0;i<(n);i++) #define debug(v) cout<<#v<<":";for(auto x:v){cout<bool chmax(T &a,const T &b){if(abool chmin(T &a,const T &b){if(b ostream &operator<<(ostream &os,const vector&v){ for(int i=0;i<(int)v.size();i++) os< istream &operator>>(istream &is,vector&v){ for(T &x:v)is>>x; return is; } #line 1 "SegmentTree/SegmentTree.cpp" template struct SegmentTree{ int sz; vector seg; Monoid M0;// モノイドの元 using F=function; F f; SegmentTree(int n,Monoid M0,F f):M0(M0),f(f){ sz=1; while(sz0;k--) seg[k]=f(seg[2*k],seg[2*k+1]); } void update(int k,Monoid x){ k+=sz; seg[k]=x; k>>=1; for(;k;k>>=1) seg[k]=f(seg[2*k],seg[2*k+1]); } Monoid query(int a,int b,int k=1,int l=0,int r=-1){ if(r==-1) r=sz; if(a<=l and r<=b) return seg[k]; if(b<=l or r<=a) return M0; Monoid L=query(a,b,2*k,l,(l+r)/2); Monoid R=query(a,b,2*k+1,(l+r)/2,r); return f(L,R); } }; signed main(){ int h,w,q;cin>>h>>w>>q; SegmentTree seg(w,0,[](int a,int b){return a+b;}); vector v(w,h); rep(i,w) seg.set(i,v[i]); seg.build(); while(q--){ int y,x;cin>>y>>x;x--; if(chmin(v[x],y-1)) seg.update(x,v[x]); cout<