#include #include using namespace std; #define faster ios::sync_with_stdio(0); cin.tie(0);cout.tie(0); #define ff first #define ss second #define ll long long int #define File freopen("input.txt","r", stdin);freopen("output.txt","w", stdout); #define testCase int tc = 1; cin >> tc;for(int i = 1;i<=tc;i++) #define INF 0x7F #define MIN_INF 0x80 #define pii acos(-1.0) const int mx = 1e5 + 111; int dir_x[] = {-1,-1,-1,0,1,1,1,0}; int dir_y[] = {-1,0,1,1,1,0,-1,-1}; ll lastonebits(int n) { return n&(-n); } template void input(vector < T> &arr) { ll a; cin >> a; arr.push_back(a); } void solve() { ll n,m,k; cin >> n >> m >> k; ll total = ((m-2ll)*4ll) + 3ll + 2ll; total = (n-1) * total; total = total + m-1; // cout << total << endl; map< pair < ll,ll >,int>blk; map < array,ll> taken; for(int i = 0;i> a >> b; blk[{a,b}] = 1; //cout << a<< " " << b << endl; } if(n == 1 && m == 1 && k > 0) { cout << 0 << endl; return; } if(n == 1 && m == 2 && k > 0) { cout << 0 << endl; return; } if(n == 2 && m == 1 && k > 0) { cout << 0 << endl; return; } ll sum = 0; for(auto i:blk) { ll count = 0; pair < int,int > node = i.ff; // cout << 's' << endl; for(int j = 0;j<8;j++) { int x = node.ff + dir_x[j]; int y = node.ss + dir_y[j]; arrayv,b; v= {node.ff,node.ss,x,y}; b= {x,y,node.ff,node.ss}; if(x >= 1 && x <= n && y >= 1 && y<=m && (taken[v] == 0 || taken[b] == 0)) { count++; taken[v] = 1; taken[b] = 1; } } // cout << count << endl; sum += count; } //sum++; cout << total - sum << endl; } int main() { faster; #ifndef ONLINE_JUDGE File #endif testCase { // cout << "Case #" << i << ": "; solve(); } }