```#include <iostream>
#include <cmath>
#include <cstring>
using namespace std;

#define N 100
#define M 100

int a[N][N];

bool adjmat[M][N], seen[N]; int matchL[M], matchR[N], m, n;
bool bpm(int u) { // Can we find augmenting path starting from u
for(int v = 0; v < n; v++) if(adjmat[u][v] && !seen[v]) { seen[v] = true;
if(matchR[v] == -1 || bpm(matchR[v]) ) { matchL[u] = v, matchR[v] = u;
return true; } }
return false; }

int main() {
int r;
cin>>r;
while(r--) {
int k;
cin>>n>>m>>k;
memset(a, 0, sizeof(a));

m = max(m, n);
n = m;

for(int i =0 ; i < k; ++i) {
double x, y;
cin>>x>>y;

a[(int)x][(int)y]++;
}

memset(adjmat, false ,sizeof adjmat);
memset(matchL,-1,sizeof matchL);
memset(matchR,-1,sizeof matchR);

for(int i=0; i < N; ++i) {
for(int j= 0 ; j < N; ++j) {
if(a[i][j] > 0) {
adjmat[i][j] = true;
}
}
}

/*for(int i = 0; i < m; ++i) {
cerr << "r " << i << ": " ;
for(int j = 0; j < m; ++j) {
if(adjmat[i][j] == true) cerr << j << ' ' ;
}
cerr << endl;
}*/

int cnt = 0;

for(int i = 0; i < m; i++) {
memset(seen, 0, sizeof seen);
if( bpm(i) ) {
cnt++; // matchL[i] is the match
}
}

cout << cnt << endl;

}
return 0;
}
```