#include<bits/stdc++.h>
using namespace std;

int n;

int main()
{
    while( ~scanf("%d",&n) )
    {
        while( n-- )
        {
            int loop;
            scanf("%d",&loop);
            int sum=0;
            for(int i=0; i<loop; ++i)
            {
                int x1,x2,y1,y2;
                scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
                sum+=( ( x2-x1+1)*(y2-y1+1) );
            }

            printf("%d\n", sum);
        }
    }

    return 0;
}