#include <stdio.h>
#include <math.h>
int main(void) {
int t,j,n, p[103][2],i,k,m;
scanf("%d",&t);
while(t--){
scanf("%d%d%d%d%d%d",&j,&p[0][0],&p[0][1],&p[1][0],&p[1][1],&n);
j=j*j;
for(i=2,n+=2;i<n;i++){ scanf("%d%d",&p[i][0],&p[i][1]); }
for(i=1,m=2;i<m;i++){
if(pow(p[i][0]-p[0][0],2)+pow(p[i][1]-p[0][1],2)<=j) break;
for(k=m;k<n;k++){
if(pow(p[i][0]-p[k][0],2)+pow(p[i][1]-p[k][1],2)<=j){
p[102][0] = p[m][0]; p[102][1] = p[m][1];
p[m][0] = p[k][0]; p[m][1] = p[k][1];
p[k][0] = p[102][0]; p[k][1] = p[102][1];
m++;
}
}
}
if(i<m) printf("YES\n");
else printf("NO\n");
}
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxtYXRoLmg+CmludCBtYWluKHZvaWQpIHsKCWludCB0LGosbiwgcFsxMDNdWzJdLGksayxtOwoJc2NhbmYoIiVkIiwmdCk7Cgl3aGlsZSh0LS0pewoJCXNjYW5mKCIlZCVkJWQlZCVkJWQiLCZqLCZwWzBdWzBdLCZwWzBdWzFdLCZwWzFdWzBdLCZwWzFdWzFdLCZuKTsKCQlqPWoqajsKCQlmb3IoaT0yLG4rPTI7aTxuO2krKyl7IHNjYW5mKCIlZCVkIiwmcFtpXVswXSwmcFtpXVsxXSk7IH0KCQlmb3IoaT0xLG09MjtpPG07aSsrKXsKCQkJaWYocG93KHBbaV1bMF0tcFswXVswXSwyKStwb3cocFtpXVsxXS1wWzBdWzFdLDIpPD1qKSBicmVhazsKCQkJZm9yKGs9bTtrPG47aysrKXsKCQkJCWlmKHBvdyhwW2ldWzBdLXBba11bMF0sMikrcG93KHBbaV1bMV0tcFtrXVsxXSwyKTw9ail7CgkJCQkJcFsxMDJdWzBdID0gcFttXVswXTsgcFsxMDJdWzFdID0gcFttXVsxXTsKCQkJCQlwW21dWzBdID0gcFtrXVswXTsgcFttXVsxXSA9IHBba11bMV07CgkJCQkJcFtrXVswXSA9IHBbMTAyXVswXTsgcFtrXVsxXSA9IHBbMTAyXVsxXTsKCQkJCQltKys7CgkJCQl9CgkJCX0KCQl9CgkJaWYoaTxtKSBwcmludGYoIllFU1xuIik7CgkJZWxzZSBwcmludGYoIk5PXG4iKTsKCX0KCXJldHVybiAwOwp9Cg==