#include <bits/stdc++.h>
using namespace std;
//fastio
#define fastio ios::sync_with_stdio(false); cin.tie(nullptr);
//iosystem,debug
#ifndef ONLINE_JUDGE 
#define debug(x) cerr << #x << " = " << x << endl;
#define iosystem freopen("in.txt", "r", stdin); freopen("out.txt", "w", stdout);
#else
#define debug(x)
#define iosystem
#endif

// #define end "\n"
const char nl = '\n';
const char* yes="YES\n";
const char* no="NO\n";

int main() {
    fastio;
    //iosystem;
    int T=1;
    cin >> T;//needed?       <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    
    while (T--) {
        
        
        
        int w,h,n;
        cin>>w>>h>>n;
        vector<vector<int>>grid(h+1,vector<int>(w+1,0));
        
        //input and (((   partial    ))) sum  >>>is written right????review it
        int x1,y1,x2,y2;
        for (int i = 0 ; i < n; i++) {
            cin>>x1>>y1>>x2>>y2;

            if(x1>x2) swap(x1,x2);
            if(y1>y2) swap(y1,y2);

            x1--,y1--,x2--,y2--;//0-indexed
            grid[y1][x1]++;

            grid[y1][x2+1]--;
            grid[y2+1][x1]--;
            
            grid[y2+1][x2+1]++;

        }
        
        //prefix sum part
        for (int i = 0 ; i < h ; i++) {
            for ( int j = 1 ; j < w ; j++) {
                grid[i][j]+=grid[i][j-1];
            }
        }
        for (int i = 1 ; i < h ; i++) {
            for ( int j = 0 ; j < w ; j++) {
                grid[i][j]+=grid[i-1][j];
            }
        }
        
        //counting
        int cnt=0;
        for(int i = 0 ; i< h; i++){
            for(int j = 0 ; j < w ;j++){
                if(!grid[i][j]) cnt++;
            }
        }

        //answer
        cout<<cnt<<nl;


        //wrong
        // int res=0;
        // for (int i = 0 ;i < h; i++) {
        //     for (int j = 0 ; j < w ; j ++) {
        //         if (grid[h-1][w-1]) res++;
        //     }
        // }
        // cout<<res<<nl;
        
        
        
    }
    
        
        
}



















