// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#define dibs reserve
#define OVER9000 1234567890
#define tisic 47
#define soclose 10e-7
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define chocolate win
#define ff first
#define ss second
#define uint unsigned int
// mylittlepony
using namespace std;
struct sur {
long long x,y;};
long long vs(sur a, sur b, sur c) {
return (b.x-a.x)*(c.y-a.y)-(b.y-a.y)*(c.x-a.x);}
bool inT(sur a, sur b, sur c, sur P) {
if(vs(b,c,P)*vs(b,c,a) < 0) return false;
if(vs(a,c,P)*vs(a,c,b) < 0) return false;
if(vs(a,b,P)*vs(a,b,c) < 0) return false;
return true;}
long long dist(sur a, sur b) {
return (a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y);}
int main() {
int T;
cin >> T;
for(int i =0; i < T; i++) {
sur tr[3];
for(int j =0; j < 3; j++) cin >> tr[j].x >> tr[j].y;
sur S; int R;
cin >> S.x >> S.y >> R;
sur a =tr[0], b =tr[1], c =tr[2];
if(inT(tr[0],tr[1],tr[2],S)) {cout << "YES\n"; continue;}
if(vs(S,a,b)*vs(S,a,b) <= R*R*dist(a,b)) {
if(dist(a,b)+dist(a,S) >= dist(b,S) && dist(a,b)+dist(b,S) >= dist(a,S))
{cout << "YES\n"; continue;}
else if(min(dist(a,S),dist(b,S)) <= R*R) {cout << "YES\n"; continue;}}
if(vs(S,c,b)*vs(S,c,b) <= R*R*dist(c,b)) {
if(dist(c,b)+dist(c,S) >= dist(b,S) && dist(c,b)+dist(b,S) >= dist(c,S))
{cout << "YES\n"; continue;}
else if(min(dist(c,S),dist(b,S)) <= R*R) {cout << "YES\n"; continue;}}
if(vs(S,a,c)*vs(S,a,c) <= R*R*dist(a,c)) {
if(dist(a,c)+dist(a,S) >= dist(c,S) && dist(a,c)+dist(c,S) >= dist(a,S))
{cout << "YES\n"; continue;}
else if(min(dist(a,S),dist(c,S)) <= R*R) {cout << "YES\n"; continue;}}
cout << "NO\n";}
return 0;}
// look at my code
// my code is amazing
Ly8gaW9zdHJlYW0gaXMgdG9vIG1haW5zdHJlYW0KI2luY2x1ZGUgPGNzdGRpbz4KLy8gYml0Y2ggcGxlYXNlCiNpbmNsdWRlIDxpb3N0cmVhbT4KI2luY2x1ZGUgPHZlY3Rvcj4KI2luY2x1ZGUgPHNldD4KI2luY2x1ZGUgPG1hcD4KI2luY2x1ZGUgPHN0cmluZz4KI2luY2x1ZGUgPHF1ZXVlPgojaW5jbHVkZSA8c3RhY2s+CiNpbmNsdWRlIDxhbGdvcml0aG0+CiNkZWZpbmUgZGlicyByZXNlcnZlCiNkZWZpbmUgT1ZFUjkwMDAgMTIzNDU2Nzg5MAojZGVmaW5lIHRpc2ljIDQ3CiNkZWZpbmUgc29jbG9zZSAxMGUtNwojZGVmaW5lIEFMTF9USEUoQ0FLRSxMSUUpIGZvcihhdXRvIExJRSA9Q0FLRS5iZWdpbigpOyBMSUUgIT0gQ0FLRS5lbmQoKTsgTElFKyspCiNkZWZpbmUgY2hvY29sYXRlIHdpbgojZGVmaW5lIGZmIGZpcnN0CiNkZWZpbmUgc3Mgc2Vjb25kCiNkZWZpbmUgdWludCB1bnNpZ25lZCBpbnQKLy8gbXlsaXR0bGVwb255CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgkKc3RydWN0IHN1ciB7Cglsb25nIGxvbmcgeCx5O307CgkKbG9uZyBsb25nIHZzKHN1ciBhLCBzdXIgYiwgc3VyIGMpIHsKCXJldHVybiAoYi54LWEueCkqKGMueS1hLnkpLShiLnktYS55KSooYy54LWEueCk7fQoKYm9vbCBpblQoc3VyIGEsIHN1ciBiLCBzdXIgYywgc3VyIFApIHsKCWlmKHZzKGIsYyxQKSp2cyhiLGMsYSkgPCAwKSByZXR1cm4gZmFsc2U7CglpZih2cyhhLGMsUCkqdnMoYSxjLGIpIDwgMCkgcmV0dXJ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