uses
	testlib, math, sysutils;

const
	EPS = 1e-4;

var
	x11, y11, x12, y12, x21, y21, x22, y22, x, y, r, d11, d12, d21, d22: extended;
	l: longint;

begin
	l := 0;
	while true do begin
    	x11 := inf.readreal;
    	y11 := inf.readreal;
    	x12 := inf.readreal;
    	y12 := inf.readreal;
    	x21 := inf.readreal;
    	y21 := inf.readreal;
    	x22 := inf.readreal;
    	y22 := inf.readreal;

    	if (x11 = 0) and (y11 = 0) and (x12 = 0) and (y12 = 0) and 
    		(x21 = 0) and (y21 = 0) and (x22 = 0) and (y22 = 0) then break;

		inc(l);

    	x := ouf.readreal;
    	y := ouf.readreal;
    	r := ouf.readreal;

    	if (abs(x) > 1e12) or (abs(y) > 1e12) then
    		quit(_wa, 'test case ' + inttostr(l) + 'invalid coordinates, too big');

       	if (r < 1e-4) or (r > 1e12) then
    		quit(_wa, 'test case ' + inttostr(l) + 'invalid radius');

    	d11 := hypot(x11 - x, y11 - y);
    	d12 := hypot(x12 - x, y12 - y);
    	d21 := hypot(x21 - x, y21 - y);
    	d22 := hypot(x22 - x, y22 - y);

    	if not( ((d11 < r - EPS) and (d12 > r + EPS)) or ((d11 > r + EPS) and (d12 < r - EPS)) ) then
    		quit(_wa, 'test case ' + inttostr(l) + 'the first segment is not correctly intersected');
    	if not( ((d21 < r - EPS) and (d22 > r + EPS)) or ((d21 > r + EPS) and (d22 < r - EPS)) ) then
    		quit(_wa, 'test case ' + inttostr(l) + 'the second segment is not correctly intersected');
    end;

  	quit(_ok, format('%d test cases', [l]));
end.