Day 2 Question 3: Extension Cords

Your solution: N:\cords\cords.{pas,c,cpp}
Input file:
Output file: cords.out

Harry the handyman needs to plug in his table saw and his arc welder at his work location. Since they each draw a lot of current, he must plug them into outlets on two different electrical circuits. Several outlets are available; each outlet is on one of several circuits. Harry has a number of extension cords of various lengths. Can Harry join some of his extension cords together so as to plug in the saw and the welder to different circuits at the same time?

The first line of input contains four numbers: x, y, n, m. x and y, both real numbers, give the coordinates of Harry's work location. n, an integer between 1 and 100, gives the number of extension cords. m, an integer between 1 and 100, gives the number of outlets. For each extension cord, a line follows which gives its length, a positive integer less than 500. For each outlet, a line follows containing a, b, and c. a and b, both real numbers, give the coordinates of the outlet. c, an integer, gives the circuit number to which the outlet is connected.

There are no obstructions on the floor so Harry can run a string of cords directly from any outlet to his work location.

If Harry can plug in his equipment, print the coordinates of any pair of outlets to which Harry can connect, in the format below. Otherwise, print "Harry is helpless."

Sample Input

100.0 100.0 3 3
100.0 106.0 1
110.0 90.0 2
89.0 111.0 3

Possible Output for Sample Input

Harry can connect to outlets at (100.0, 106.0) and (110.0, 90.0).