// 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