AirDrop
InterviewTime limit1sMemory limit1024 MB
Find which friends holding a photo Puang can receive, directly or through relay friends within distance K and version gap T.
Problem
Puang lives on a two-dimensional plane and has just enrolled at university as a freshman. Being outgoing, Puang made friends at university and plans to call them friend , friend , , friend .
Puang took photos with some of these friends. Puang wants to receive those photos but finds moving around tiresome, so Puang plans to receive them by AirDrop while sitting still.
AirDrop can send a photo only to a device whose version differs from the sender's phone by at most and whose Euclidean distance is at most . Even if the version difference between Puang and a friend who holds a photo is greater than , Puang can still receive the photo through an indirect path via other friends.
Puang wants to receive as many photos as possible using the friends Puang knows. Find every photo Puang can receive.
Input
The first line contains the number of friends , the maximum AirDrop distance , and the maximum phone version difference , separated by spaces.
The second line contains Puang's coordinates and Puang's phone version , , , separated by spaces.
From the third line onward, the next lines describe Puang's friends. The -th line contains friend 's information , , , , separated by spaces. and are coordinates, and is the phone version. If is 0, Puang did not take a photo with friend . If is 1, Puang took a photo with friend .
Output
On the first line, print the numbers of the friends who initially had a photo that Puang can receive, in ascending order, separated by spaces.
If Puang can receive no photos, print 0.
Constraints
- All given coordinates are distinct.
- All given input values are integers.