1. Java, Peter Schnitzler


/* Problem : 191
* Author : Peter Schnitzler
* Status : AC
* Runtime : 0.12
*/

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.LinkedList;
import java.util.StringTokenizer;


public class Main
{

/**
* @param args
*/
public static void main(String[] args) throws Exception
{
BufferedReader read = new BufferedReader(new InputStreamReader(System.in));

int rounds = Integer.parseInt(read.readLine().trim());


for (int c = 0; c < rounds; c++)
{
StringTokenizer tok = new StringTokenizer(read.readLine());

int xStart = Integer.parseInt(tok.nextToken());
int yStart = Integer.parseInt(tok.nextToken());
int xEnd = Integer.parseInt(tok.nextToken());
int yEnd = Integer.parseInt(tok.nextToken());


int xLeft = Integer.parseInt(tok.nextToken());
int yTop = Integer.parseInt(tok.nextToken());
int xRight = Integer.parseInt(tok.nextToken());
int yBottom = Integer.parseInt(tok.nextToken());


//ordering input
if (xRight < xLeft)
{
int temp = xRight;
xRight = xLeft;
xLeft = temp;
}

if (yTop < yBottom)
{
int temp = yTop;
yTop = yBottom;
yBottom = temp;
}


//sorgt dafür das die Startkordinate "Links" ist
if (xEnd < xStart)
{
int temp = xEnd;
xEnd = xStart;
xStart = temp;

temp = yEnd;
yEnd = yStart;
yStart = temp;
}


//einer der Punkte ist im Rechteck??
if (getState(xStart, xLeft, xRight) == 0 && getState(yStart, yBottom, yTop) == 0)
{
System.out.println("T");
continue;
}

if (getState(xEnd, xLeft, xRight) == 0 && getState(yEnd, yBottom, yTop) == 0)
{
System.out.println("T");
continue;
}





//Spezialfälle
//die Linie ist senkrecht
if (xStart == xEnd)
{
if (getState(xStart, xLeft, xRight) != 0)
{
System.out.println("F");
continue;
}


if (yEnd < yStart)
{
int temp = yEnd;
yEnd = yStart;
yStart = temp;
}

if (getState(yTop, yStart, yEnd) == 0 || getState(yBottom, yStart, yEnd) == 0)
{
System.out.println("T");
}
else
{
System.out.println("F");
}
continue;
}


//Die Linie ist Wagerecht
if (yStart == yEnd)
{
if (getState(yStart, yBottom, yTop) != 0)
{
System.out.println("F");
continue;
}

if (getState(xLeft, xStart, xEnd) == 0 || getState(xRight, xStart, xEnd) == 0)
{
System.out.println("T");
}
else
{
System.out.println("F");
}
continue;
}


double xDiff = xEnd - xStart;
double yDiff = yEnd - yStart;

//die anzahl von y Kordinaten die für eine x Kordinate überquert wird
double ySteig = yDiff / xDiff;


//crosses the line the left side
if (getState(xLeft, xStart, xEnd) == 0)
{
int temp = xLeft - xStart;

double yPos = ySteig * temp + yStart;

if (yPos <= yTop && yPos >= yBottom)
{
System.out.println("T");
continue;
}
}


//crosses the line the right side
if (getState(xRight, xStart, xEnd) == 0)
{
int temp = xRight - xStart;

double yPos = ySteig * temp + yStart;

if (yPos <= yTop && yPos >= yBottom)
{
System.out.println("T");
continue;
}
}



//sorgt dafür das die Startkordinate "Unten" ist
if (yEnd < yStart)
{
int temp = xEnd;
xEnd = xStart;
xStart = temp;

temp = yEnd;
yEnd = yStart;
yStart = temp;
}


//die Anzahl von x Kordinaten die für eine y kordinate überquert wird
double xSteig = xDiff / yDiff;


//crosses the line the bottom side
if (getState(yBottom, yStart, yEnd) == 0)
{
int temp = yBottom - yStart;

double xPos = xSteig * temp + xStart;

if (xPos <= xRight && xPos >= xLeft)
{
System.out.println("T");
continue;
}
}

//crosses the line the top side
if (getState(yTop, yStart, yEnd) == 0)
{
int temp = yTop - yStart;

double xPos = xSteig * temp + xStart;

if (xPos <= xRight && xPos >= xLeft)
{
System.out.println("T");
continue;
}
}



System.out.println("F");
}

}


private static int getState(int n, int min , int max)
{
if (n < min) return -1;

if (n > max) return 1;

return 0;
}



private static int euclid (int a, int b)
{
if (b == 0)
return a;

return euclid (b, a % b);
}

}