#include using namespace std; typedef long long ll; const int N=8e6+5; char buf[1<<23],*p1=buf,*p2=buf; #define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<23,stdin),p1==p2)?EOF:*p1++) template void read(rd &x){ char c=getchar(); for(;c<48||c>57;c=getchar()); for(x=0;c>47&&c<58;c=getchar())x=(x<<1)+(x<<3)+(c^48); } int n1,n2,n3,m,S,T; int s[3][N],ln[3],pr[3][N],su[3][N]; long long ans; pairid(int x){ if(x<=n1)return {0,x}; if(x<=n2+n1)return {1,x-n1}; return {2,x-n1-n2}; } struct node{ int l,r,ct; }a1[N],a2[N]; int main(){ read(n1),read(n2),read(n3),read(m); S=n1+n2+n3+1,T=S+1; ln[0]=n1,ln[1]=n2,ln[2]=n3; for(int i=0;i<3;++i)for(int j=0;j<=T;++j)pr[i][j]=-1,su[i][j]=N; for(int i=1,x,y;i<=m;++i){ read(x),read(y); if(x>y)swap(x,y); if(x==S)return puts("0"),0; auto [a,b]=id(x); if(y==S||y==T){ if(y==S)++s[a][0],--s[a][b]; else ++s[a][b]; continue; } auto [c,d]=id(y);//printf("?%d %d %d %d\n",a,b,c,d); if(a==c){ ++s[a][b]; --s[a][d]; continue; } if(!a)pr[c-1][b]=max(pr[c-1][b],d),su[c-1][b]=min(su[c-1][b],d); else pr[2][b]=max(pr[2][b],d),su[2][b]=min(su[2][b],d); } for(int i=0;i<3;++i){ for(int j=1;j<=T;++j)pr[i][j]=max(pr[i][j],pr[i][j-1]); for(int j=T-1;~j;--j)su[i][j]=min(su[i][j],su[i][j+1]); } for(int i=0;i<3;++i)for(int j=1;j<=ln[i];++j)s[i][j]+=s[i][j-1]; for(int i=0,j;j=i,i<=ln[0];i=j+1){ if(pr[0][i]>=su[0][i+1])continue; int l=pr[0][i],r=su[0][i+1]-1; while(j=su[1][k+1])continue; int L=pr[1][k],R=su[1][k+1]-1; if(c1&&a1[c1].l==L)++a1[c1].ct; else a1[++c1]={L,R,1}; } for(int k=l;k<=r;++k){ if(s[1][k]||pr[2][k]>=su[2][k+1])continue; int L=pr[2][k],R=su[2][k+1]-1; if(c2&&a2[c2].l==L)++a2[c2].ct; else a2[++c2]={L,R,1}; } if(!c1||!c2)continue; int o=max(0,max(a1[1].l,a2[1].l)),p1=1,p2=1; //for(int k=1;k<=p1;++k)printf("1 %d %d %d\n",a1[k].l,a1[k].r,a1[k].ct); //for(int k=1;k<=p2;++k)printf("2 %d %d %d\n",a2[k].l,a2[k].r,a2[k].ct); while(p1<=c1&&o>a1[p1].r)++p1; while(p2<=c2&&o>a2[p2].r)++p2; while(o<=ln[2]&&p1<=c1&&p2<=c2){ if(!s[2][o]&&o>=a1[p1].l&&o>=a2[p2].l)ans+=1ll*a1[p1].ct*a2[p2].ct; if(o==a1[p1].r)++p1; if(o==a2[p2].r)++p2; ++o; }//printf("%lld\n",ans); } printf("%lld\n",ans); return 0; }