#include<bits/stdc++.h>
using namespace std;
inline void read(int &s){
s=0;char c=getchar();
while(c<'0'||c>'9')c=getchar();
for(;c>='0'&&c<='9';c=getchar())s=(s<<1)+(s<<3)+(c^48);
}
int n;
int dt[1005][1005],b[1005][1005];
struct node{
int x,y,t;
};
void bfs(){
queue <node> q;
node a;
a.x=1; a.y=1; a.t=0;
q.push(a);
while(!q.empty()){
a=q.front(); q.pop();
int x=a.x, y=a.y, t=a.t;
if(x==n && y==n){
puts("Yes");
return;
}
if(x+1<=n && (t+1<=dt[x+1][y] || dt[x+1][y]==-1) && b[x+1][y]==0){
b[x+1][y]=1;
a.x=x+1, a.y=y, a.t=t+1;
q.push(a);
}
if(x-1>=1 && (t+1<=dt[x-1][y] || dt[x-1][y]==-1) && b[x-1][y]==0){
b[x-1][y]=1;
a.x=x-1, a.y=y, a.t=t+1;
q.push(a);
}
if(y-1>=1 && (t+1<=dt[x][y-1] || dt[x][y-1]==-1) && b[x][y-1]==0){
b[x][y-1]=1;
a.x=x, a.y=y-1, a.t=t+1;
q.push(a);
}
if(y+1<=n && (t+1<=dt[x][y+1] || dt[x][y+1]==-1) && b[x][y+1]==0){
b[x][y+1]=1;
a.x=x, a.y=y+1, a.t=t+1;
q.push(a);
}
}
puts("No");
}
int main(){
int t;cin>>t;
while(t--){
memset(dt,-1,sizeof(dt));
memset(b,0,sizeof(b));
cin>>n;
for(int i=1;i<=n;i++){
int x,y;
read(x);read(y);
dt[x][y]=i;
}
bfs();
}
return 0;
}