#include #include #include #include using namespace std; #define FNAME "inside.txt" #define cin fin ifstream fin(FNAME); #define ANTI_CLOCKWISE 1 #define PARALLEL 0 #define CLOCKWISE (-1) class Point { public: int x, y; }; int direction( const Point &a, const Point &b, const Point &c ) { const int bx = b.x - a.x; const int by = b.y - a.y; const int cx = c.x - a.x; const int cy = c.y - a.y; const int outprod = bx*cy - by*cx; if ( outprod == 0 ) return PARALLEL; return (outprod > 0)? ANTI_CLOCKWISE : CLOCKWISE; } bool inside( const vector &P, const Point &p, int ind ) { for ( int i = 0; i < P.size(); i++ ) { const int j = (i+1)%P.size(); const int d = direction(P[i], P[j], p); if ( d != PARALLEL && d != ind ) return false; } return true; } int main() { int nver, npoint; for ( int nt = 1; cin >> nver >> npoint; nt++ ) { if ( nver == 0 && npoint == 0 ) break; vector POLY(nver), PS(npoint); for ( int i = 0; i < nver; i++ ) cin >> POLY[i].x >> POLY[i].y; for ( int i = 0; i < npoint; i++ ) cin >> PS[i].x >> PS[i].y; bool exsClock = false; bool exsAnti = false; for ( int i = 2; i < nver; i++ ) { const int d = direction(POLY[0], POLY[1], POLY[i]); if ( d == CLOCKWISE ) exsClock = true; if ( d == ANTI_CLOCKWISE ) exsAnti = true; } assert ( exsClock ^ exsAnti ); int indirection = (exsClock)? CLOCKWISE : ANTI_CLOCKWISE; int ninside = 0; for ( int i = 0; i < PS.size(); i++ ) if ( inside(POLY, PS[i], indirection) ) ninside++; cout << "Data set " << nt << ": " << ninside << endl; } return 0; }