1. 

/**
* FWP, Ausgew√¤hlte Probleme aus dem ACM Programming Contest, SS10
* Problem: 191 - Intersection
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&category=3&problem=127&mosmsg=Submission+received+with+ID+8013144
*
* @author Evgeni Pavlidis
* @version 1.0, 06/02/2010
*
* Method : Comp. Geometry
* Status : Accepted
* Runtime: 0.180
*/

/* For the interseting algorithm see: http://www.topcoder.com/tc?module=Static&d1=tutorials&d2=geometry2 */

import java.io.*;
import java.util.*;

class Main
{

private final static double e = 0.0000000001;

private static class Line
{
double a,b,c;
double xMin,xMax,yMin,yMax;

Line(double x1, double y1, double x2, double y2)
{
a = y2-y1;
b = x1-x2;
c = a*x1+b*y1;
xMin = Math.min(x1,x2);
xMax = Math.max(x1,x2);
yMin = Math.min(y1,y2);
yMax = Math.max(y1,y2);
}
}

private static boolean intersects(Line l1, Line l2)
{
double det = l1.a*l2.b - l2.a*l1.b;

// this case is not interesting since we have to
// check if the two points are in the square anyway
if(det == 0)
return false;

// calc intersection point
double x = (l2.b*l1.c - l1.b*l2.c)/det;
double y = (l1.a*l2.c - l2.a*l1.c)/det;

// check if point on both line segements
if(x < l1.xMin-e || x > l1.xMax+e || y < l1.yMin-e || y > l1.yMax+e)
return false;

if(x < l2.xMin-e || x > l2.xMax+e || y < l2.yMin-e || y > l2.yMax+e)
return false;

return true;
}

public static void main(String... args)
{
Scanner scanner = new Scanner(System.in);
int testCases = scanner.nextInt();


double xstart, ystart, xend, yend, xleft, ytop, xright, ybottom;

for(int c = 0; c < testCases; c++)
{
xstart=scanner.nextDouble();
ystart=scanner.nextDouble();
xend=scanner.nextDouble();
yend=scanner.nextDouble();
xleft=scanner.nextDouble();
ytop=scanner.nextDouble();
xright=scanner.nextDouble();
ybottom=scanner.nextDouble();

double tmp;
if(xleft > xright)
{
tmp = xleft;
xleft = xright;
xright = tmp;
}
if(ytop < ybottom )
{
tmp = ybottom;
ybottom = ytop;
ytop = tmp;
}



String output = "F";

Line l = new Line(xstart,ystart,xend,yend);

// line intersects left border
if(intersects(l, new Line(xleft, ybottom, xleft, ytop)))
output = "T";

// line intersects right border
if(intersects(l, new Line(xright, ybottom, xright, ytop)))
output = "T";

// line intersects top border
if(intersects(l, new Line(xleft, ytop, xright, ytop)))
output = "T";

// line intersects bottom border
if(intersects(l, new Line(xleft, ybottom, xright, ybottom)))
output = "T";


// start point in the square
if(xstart > xleft-e && xstart < xright+e)
if(ystart > ybottom-e && ystart < ytop+e)
output = "T";

// end point in the square
if(xend > xleft-e && xend < xright+e)
if(yend > ybottom-e && yend < ytop+e)
output = "T";


System.out.println(output);
}
}
}