#include using namespace std; using LL=long long; const int mo=1e9+7; LL qpow(LL a,LL b) { LL ans=1; a%=mo; while(b) { if(b&1) ans=ans*a%mo; b>>=1; a=a*a%mo; } return ans; } //----------------------------------------------------- const int maxn=1005; struct node { int a,b; }p[maxn]; int main() { int T; scanf("%d",&T); int i,n; while(T--) { scanf("%d",&n); for(i=0;ity) { if(p[i].a>ri) { ans+=(p[i].a-ri)/2; if(p[i].a-ri&1) { le=p[i].a; ri=min(le+1,p[i].b); ans++; } else { le=ri=p[i].a; } } else { ans+=(le-p[i].b)/2; if(le-p[i].b&1) { ri=p[i].b; le=max(ri-1,p[i].a); ans++; } else le=ri=p[i].b; } } else { le=tx,ri=ty; } } printf("%d\n",ans); } return 0; } /* 100 5 5 5 1 1 6 6 2 2 5 5 */