#include using namespace std; #define rep(i,n) for(int i=0;i,3>ng; array,3>ok; array,3>ok2; array,3>rectx; array,3>recty; array>,3>judgex; array>,3>judgey; vectorv; void pre(){ int sz=rectx[2].size(); v.resize(sz); rep(i,sz-1){ if(ok2[2][i]){ v[i+1]=max(0LL,ok[1][rectx[2][i+1]]-ok[1][rectx[2][i]]) *max(0LL,ok[2][recty[2][i+1]]-ok[2][recty[2][i]]); } } rep(i,sz-1)v[i+1]+=v[i]; } lint get(lint l,lint r){ if(r<=l)return 0LL; return v[r]-v[l]; } lint getsum(lint p,lint q,lint r,lint s){ int sz=rectx[2].size(); lint ans=0; auto a=upper_bound(all(rectx[2]),p)-rectx[2].begin()-1; auto b=lower_bound(all(rectx[2]),q)-rectx[2].begin(); auto c=upper_bound(all(recty[2]),r)-recty[2].begin()-1; auto d=lower_bound(all(recty[2]),s)-recty[2].begin(); lint left=max(a,c),right=min(b,d); //cerr<n; lint m; rep(i,3)cin>>n[i]; cin>>m; vectors(m),t(m),a(m),b(m),u(m),v(m); lint n1=n[0],n2=n[0]+n[1],n3=n[0]+n[1]+n[2]; rep(i,m){ cin>>u[i]>>v[i]; u[i]--;v[i]--; if(u[i]>v[i])swap(u[i],v[i]); if(u[i]==n3){ cout<<0<b[i])swap(a[i],b[i]); ng[s[i]][a[i]]++; ng[t[i]][b[i]]--; }else{ if(s[i]>t[i]){ swap(s[i],t[i]); swap(a[i],b[i]); } int idx=s[i]+t[i]-1; rectx[idx].emplace_back(a[i]); recty[idx].emplace_back(b[i]); judgex[idx].emplace_back(a[i],i); judgey[idx].emplace_back(b[i],i); } } rep(i,3)rep(j,n[i])ng[i][j+1]+=ng[i][j]; rep(i,3)rep(j,n[i])ok[i][j+1]=(ng[i][j]==0); rep(i,3)rep(j,n[i])ok[i][j+1]+=ok[i][j]; rep(i,3)sort(all(rectx[i])); rep(i,3)sort(all(recty[i])); rep(i,3)sort(all(judgex[i])); rep(i,3)sort(all(judgey[i])); rep(i,3)ok2[i].resize(rectx[i].size()-1,0); rep(i,3){ ok2[i][0]=1; maptmp; rep(j,judgex[i].size()){ tmp[judgex[i][j].second]++; tmp[judgey[i][j].second]--; if(tmp[judgex[i][j].second]==0)tmp.erase(judgex[i][j].second); if(tmp[judgey[i][j].second]==0)tmp.erase(judgey[i][j].second); if(tmp.size()==0){ ok2[i][j+1]=1; } //cerr<=rectx[0][id1+1])id1++; while(i>=rectx[1][id2+1])id2++; if(!ok2[0][id1]||!ok2[1][id2])continue; ans+=getsum(recty[0][id1],recty[0][id1+1],recty[1][id2],recty[1][id2+1]); //cerr<