#include #define int long long using namespace std; const int N=4e5+10; int n,tot,ans,m,topz,limz,topy,limy,md; int lsh[N<<1]; //bool jg[N<<1]; vector bj[2][N<<1]; struct node{ int l1,r1,l2,r2; }a[N]; bool cmp(node x,node y){ if(x.l2!=y.l2) return x.l2>ID>>T; while(T--){ cin>>n; for(int i=1;i<=n;++i) cin>>a[i].l1>>a[i].r1>>a[i].l2>>a[i].r2,lsh[++tot]=a[i].l2,lsh[++tot]=a[i].r2,limy+=a[i].l1,topy+=a[i].r1; sort(lsh+1,lsh+1+tot); m=unique(lsh+1,lsh+1+tot)-lsh-1; //for(int i=1;i<=m;i++) cout<0 && (check(limy,topy,limz,topz) || (topy((topy+limz+md))) || (topz=((topz+limy+md+1)/2)))) ans+=lsh[i]-lsh[i-1]-1; //cout<0 && (check(limy,topy,limz,topz) || (topy((topy+limz+md))) || (topz=((topz+limy+md+1)/2)))) ans++; //cout<