#include #include #include using namespace std; struct Point { Point(double _x = 0, double _y = 0): x(_x), y(_y) {} double x, y; }; double Dist(const Point &p, const Point &q) { double dx = q.x - p.x, dy = q.y - p.y; return sqrt(dx*dx + dy*dy); } Point Extend(const Point &p, const Point &q) { double d = Dist(p, q), dx = (q.x - p.x) / d, dy = (q.y - p.y) / d; return Point(q.x + 2*dx, q.y + 2*dy); } bool IsHit(const Point &s1, const Point &s2, const Point &p) { double a = Dist(s1, s2), b = Dist(s1, p), c = Dist(s2, p); if (b <= 2 || c <= 2) return true; double h = fabs((s2.x - s1.x) * (p.y - s1.y) - (s2.y - s1.y) * (p.x - s1.x)) / a; return (a*a + b*b > c*c && a*a + c*c > b*b && h < 2); } bool IsGoodShot(const Point &p1, const Point &p2, const Point &p3, const vector &balls) { Point hit = Extend(p3, p2); for (int i = 0; i < int(balls.size()); i++) { if (IsHit(p1, hit, balls[i])) return false; if (IsHit(hit, p3, balls[i])) return false; } double a = Dist(p1, hit), b = Dist(hit, p3), c = Dist(p1, p3); return a*a + b*b < c*c - 1e-10; } int main() { Point pockets[] = {Point(0, 0), Point(54, 0), Point(108, 0), Point(0, 54), Point(54, 54), Point(108, 54)}; Point p1, p2; int n; while ((cin >> p1.x) && (p1.x != 0) && (cin >> p1.y >> p2.x >> p2.y >> n)) { vector balls(n); for (int i = 0; i < n; i++) cin >> balls[i].x >> balls[i].y; int cnt = 0; for (int i = 0; i < 6; i++) if (IsGoodShot(p1, p2, pockets[i], balls)) { if (cnt++ > 0) cout << " "; cout << (i+1); } if (cnt == 0) cout << "no shot"; cout << endl; } return 0; }