//BISMILLAHIRRAHMANIRRAHIM /*  manus tar shopner soman boro  Author :: Shakil Ahmed .............AUST_CSE27.........  prob   ::  uva 11331  Type   ::  Bi-coloring with Dp  verdict::  Yes  */  #include <stdio.h> #include <string.h> #include <stdlib.h> #include <ctype.h> #include <math.h> #include <limits.h> #include <set> #include <algorithm> #include <iostream> #include <vector> #include <stack> #include <string> #include <list> #include <map> #include <queue> #include <sstream> #include <utility> #define pf(a) printf("%d\n",a) #define pf2(a,b) printf("%d %d\n",a,b) #define pfcs(cs,a) printf("Case %d: %d\n",cs,a) #define sc(a) scanf("%d",&a) #define sc2(a,b) scanf("%d %d",&a,&b) #define pb push_back #define mp make_pair #define pi acos(-1.0) #define ff first #define LL long long #define ss second #define rep(i,n) for(i = 0; i < n; i++) #define REP(i,n) for(i=n;i>=0;i--) #define FOR(i,a,b) for(int i = a; i <= b; i++) #define ROF(i,a,b) for(int i = a; i >= b; i--) #define re return #define QI queue<int> #define SI stack<int> #define pii pair <int,int> #define MAX #define MOD #define INF 1<<30 #define SZ(x) ((int) (x).size()) #define ALL(x) (x).begin(), (x).end() #define sqr(x) ((x) * (x)) #define memo(a,b) memset((a),(b),sizeof(a)) #define G() getchar()   using namespace std;   template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); } template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); } vector <int> adj[2005], nilam; int color[2005]; bool visit[2005]; int a[2005][2],dp[1005][1005],idx,b,c; bool flag; bool dfs(int node,int c) {   int i;     nilam.pb(node);     visit[node]=1;     color[node]=c;     for(i=0;i<adj[node].size();i++)     {         if(visit[adj[node][i]] && color[adj[node][i]]==c) return false;         if(!visit[adj[node][i]]) dfs(adj[node][i],(c+1)%2);      }   return true; } int DP(int cur,int niyechi) {        if(cur==idx)        {   if(niyechi==b) return 1;            else return 0;        }        if(dp[cur][niyechi]!=-1) return dp[cur][niyechi];        dp[cur][niyechi]=max(DP(cur+1,a[cur][0]+niyechi),DP(cur+1,a[cur][1]+niyechi));        return dp[cur][niyechi]; }  int main() {      //freopen("in.txt", "r", stdin);     int cs,T;     sc(T);     FOR(cs,1,T)     {            int n,w,m,k,u,v,i,j,one=0,two=0,ct=0;            cin>>b>>c>>m;            n=b+c;            FOR(i,1,n)  { adj[i].clear(); color[i]=-1; visit[i]=0;}            flag=true;            rep(i,m)            {                   cin>>u>>v;                   adj[u].pb(v);                   adj[v].pb(u);            }            bool check=true;          //  memo(color,0               idx=0;                   nilam.clear();                              FOR(i,1,n) if(!visit[i])                             {  if(!dfs(i,0))  { check=false; break; }                                 int one=0,zero=0;                                 rep(j,SZ(nilam))                                 {                                        if(color[nilam[j]]==1) one++;                                        else zero++;                                 }                                   a[idx][0]=one;                                   a[idx++][1]=zero;                                   nilam.clear();                               }             if(!check) { puts("no"); continue; }            memo(dp,-1);             if(DP(0,0))             puts("yes");            else puts("no");       }   }