#include #include #include #include #include using namespace std; int N,H,W; setS[1002]; vector >P[1000]; bool white[1002*1002]; const int d[5]={0,1,0,-1,0}; bool ans[1000]; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cin>>N>>H>>W; H+=2;W+=2; for(int x=0;x>lx>>rx>>ly>>ry; rx++,ry++; for(int x=lx;x=H||ty>=W)continue; int id=tx*W+ty; if(white[id])uf.merge(w,id); } }; for(int x=0;x