#include using namespace std; int w, h, q; void assign(int * to, int * from){ for(int j=0; jquery(h, h+1); if(!isId(p)) tree->update(h, id); else{ for(int j=0; jupdate(h, tmp); } } void debug_out(const int * perm){ for(int j=0; j> w >> h >> q; for(int j=0; j < w; j++) id[j] = j; tree = new Tree(h, id); for(int i=0; i> y >> x1 >> x2; x1 = min(x1, x2); x1--; y--; toggle(y, x1); int * perm = tree->query(0, h); //debug_out(perm); int count = 0; memset(ra, 0, sizeof(ra)); for(int j=0; j