1.

/**
* ACM Training 2009
* ACM Problem #378 - Intersecting Lines
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=5&page=show_problem&problem=314
*
* @author Dennis Wilfert
* @version 1.0, 09/14/2009
*
* Methode: Geradengleichung
* Status : Accepted
* Runtime: 0.084
*/
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.text.DecimalFormat;
import java.util.StringTokenizer;

public class Main {

public static void main(String... args) throws NumberFormatException, IOException{

BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
PrintWriter writer = new PrintWriter(new BufferedOutputStream(System.out));

StringTokenizer token;

double[][] coordinates = new double[4][4];

int i;
double x, y;

DecimalFormat df = new DecimalFormat();
df.applyPattern( "0.00" );

writer.println("INTERSECTING LINES OUTPUT");
for(int cases = Integer.parseInt(reader.readLine()); cases > 0; cases--){

token = new StringTokenizer(reader.readLine());
for(i = 0; i < 4; i++){
coordinates[i][0] = Double.parseDouble(token.nextToken());
coordinates[i][1] = Double.parseDouble(token.nextToken());
}

// m und n für die Geradengleichung berechnen

// m
coordinates[0][2] = (coordinates[1][1] - coordinates[0][1]) / (coordinates[1][0] - coordinates[0][0]);
// n
coordinates[0][3] = coordinates[1][1] - coordinates[0][2] * coordinates[1][0];

// m
coordinates[2][2] = (coordinates[3][1] - coordinates[2][1]) / (coordinates[3][0] - coordinates[2][0]);
// n
coordinates[2][3] = coordinates[3][1] - coordinates[2][2] * coordinates[3][0];

// Mindestens eine gerade ist parallel zur y-Achse
if(Double.isInfinite(coordinates[0][2]) || Double.isInfinite(coordinates[2][2])){
// Beide sind parallel zur y-Achse
if(Double.isInfinite(coordinates[0][2]) && Double.isInfinite(coordinates[2][2]))
writer.println(coordinates[0][0] == coordinates[2][0] ? "LINE" : "NONE");
else{
if(Double.isInfinite(coordinates[0][2]))
writer.println("POINT " + df.format(coordinates[0][0]) + " " + df.format(coordinates[2][2]*coordinates[0][0] + coordinates[2][3]));
else
writer.println("POINT " + df.format(coordinates[2][0]) + " " + df.format(coordinates[0][2]*coordinates[2][0] + coordinates[0][3]));
}
}
else{
// Beide Geraden sind parallel zur x-Achse
if(coordinates[0][2] == 0 && coordinates[2][2] == 0)
writer.println(coordinates[0][1] == coordinates[2][1] ? "LINE" : "NONE");
else{
// x und y Koordinaten des Schnittpunkts berechnen
x = (coordinates[2][3] - coordinates[0][3]) / (coordinates[0][2] - coordinates[2][2]);
y = coordinates[0][2]*x + coordinates[0][3];

writer.println(Double.isNaN(x) || Double.isNaN(y) ? "LINE" : (Double.isInfinite(x) || Double.isInfinite(y) ? "NONE" : "POINT " + df.format(x) + " " + df.format(y)));
}
}
}
writer.println("END OF OUTPUT");
writer.flush();

}

}