# Fencing Question

#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define deb(x) cout << #x << " " << x << endl;
#define fi(i,a,b) for(int i = a; i<b; i++)
#define fd(i,a,b) for(int i = a; i>=b; i–)
#define ll long long int
#define pii pair<int, int>
#define vi vector
#define N 1000000007
#define endl “\n”
#define pq priority queue
#define pb push_back
#define pf push_front
#define mt make_tuple
#define mp make_pair
#define present(container, element) (container.find(element) != container.end())
#define cpresent(container, element) (find(all(container),element) != container.end())
#define tr(container, it)
for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)

#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define en end()

#define cy cout<<“YES”<<endl;
#define cn cout<<“NO”<<endl;
#define prec(a) fixed<<setprecision(9)<<a
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
const long double PI = (long double)(3.1415926535897932384626433832795);
using namespace std;

//*****************************

void solve()
{ ll n,m,k,z=0;
ll b,c;
cin>> n>>m>>k;
vector<vector>a(n,vector(m,0));

vector<pair<ll,ll>>x;

fi(i,0,k)
{
cin>>b;
cin>>c;
a.push_back({b,c});
a[b-1][c-1]=1;
}
vector<pair<ll,ll>>::iterator it=x.begin();
fi(i,0,k)
{
if(a[it->first-2][it->second-1]==0)
{
z++;

}
if(a[it->first-0][it->second-1]==0)
{
z++;

}
if(a[it->first-1][it->second-2]==0)
{
z++;

}
if(a[it->first-1][it->second-0]==0)
{
z++;
}

if((it->first==1)||(it->second==1))
{
z++;
}
if((it->first==n)||(it->second==m))
{
z++;
}
if(i!=k-1)
it++;

}
cout<<z<<endl;

}

int main(){

//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
IOS;

int t; cin >>t;
while(t--){solve();}
return 0 ;

}