#include<bits/stdc++.h>
using namespace std;
int d[2][2] = {{0,1},{1,0}}; //两个方向
const int N = 10005;
int mp[N][N]={0}; //地图
int vis[N][N]={0}; //标记是否搜过
int cn=0;
void bfs(int n,int m,int k) {
queue<pair<int, int>> q;
q.push({1,1});
vis[1][1] = 1;
if( mp[1][1]==1 ) cn++;
while (q.size()) {
pair<int, int> t = q.front(); ///入队列出队列巨费时间,时间远不止O(
q.pop();
int tx = t.first, ty = t.second;
for (int i = 0; i < 2; i++) { //扩展(tx,ty)的2个邻居
int nx = tx + d[i][0], ny = ty + d[i][1];
if( vis[nx][ny] == 0 && nx>=1 && nx<=n && ny>=1 && ny<=m ) {
vis[nx][ny] = 1; //注意:这一句必不可少
q.push({nx, ny});
if( mp[nx][ny]==1 ) cn++;
}
}
}
if( cn==k ) cout<<"YES\n";
else cout<<"NO\n";
}
int main() {
int T;cin>>T;
while( T-- ) {
int n,m,x,y,k;
cin>>n>>m>>k;
mp[n+5][m+5]={0};//初始化
vis[n+5][m+5]={0};//初始化
for(int i=0;i<k;i++) { O(K)
cin>>x>>y;
mp[x][y]=1;
}
cn=0;//初始化
bfs(n ,m, k); //O(2K)
}
return 0;
}
bool cmp(node a ,node b){ //行数升序排列
if(a.x!=b.x)return a.x<b.x;
return a.y<b.y;
}
int main(){
std::ios::sync_with_stdio(0);
cin.tie(0),cout.tie(0)
ll n,m,k,ok=1; cin>>n>>m>>k;
for(int i=1;i<=k;i++){ //2*1e5
int x,y;
cin>>x>>y;
t[i]={x,y};
}
sort(t+1,t+1+k,cmp); //2*1e5*(1+log2 1e5)
int ed=t[1].y;
for(int i=2;i<=k;i++){ //2*1e5
if(t[i].y<ed){ //一旦出现y值减小的格子,铁定取不完了
ok=0;
break;
}
else
ed=t[i].y;
}
if(ok)cout<<"YES\n";