#include <iostream>#include <vector>using namespace std;const int MAXSIZE = 100;const double Max = 100000000;struct Point{ double x; double y;}points[MAXSIZE];Point pc;double CrossMultiply(const Point& a,const Point& b,const Point& c) { double x1,y1,x2,y2; x1= b.x - a.x; y1 = b.y - a.y; x2 = c.x - b.x; y2 = c.y - b.y; return x1 * y2 - x2 * y1;} double interSect(const Point& a,const Point& b,const Point& c,const Point& d){ double d1,d2,d3,d4; d1 = CrossMultiply(a,b,c), d2 = CrossMultiply(a,b,d), d3 = CrossMultiply(c,d,a), d4 = CrossMultiply(c,d,b); if((d1 * d2) < 0 && (d3 * d4) < 0) return 1.; else if((d1 * d2) == 0 || (d3 * d4) == 0) return 0; else return -1.;}bool IsonEdge(const Point& p,const vector<Point>& ptVect){ int i,j,size,minX,maxX,minY,maxY; size = ptVect.size(); for (i=0;i<size;++i) { j= i+1; if (j==size) { j=0; } if (CrossMultiply(ptVect[i],ptVect[j],p)==0) { if (p.x>=min(ptVect[i].x,ptVect[j].x)&&p.x<=max(ptVect[i].x,ptVect[j].x)&&p.y>=min(ptVect[i].y,ptVect[j].y)&&p.y<=max(ptVect[i].y,ptVect[j].y)) { return true; } } } return false;}bool isInside(const Point& p,const vector<Point>& ptVect){ int i,j,num,size; double d; num = 0; size = ptVect.size(); for(i = 0 ; i <size; ++i) {j= i+1; if (j==size) { j=0; } d = interSect(p,pc,ptVect[i],ptVect[j]); if(d > 0) num++; else if(d == 0) { if(ptVect[i].y > 0 || ptVect[j].y > 0) num++; } } if(num % 2 == 0) return false; else return true;}int main(void){ int N,M,i,pX,pY,cases=0; while (cin>>N&&N!=0) { cin>>M; if(cases != 0) cout << endl; vector<Point> pointVect; for (i=0;i<N;++i) { cin>>points[i].x>>points[i].y; pointVect.push_back(points[i]); } cout << "Problem " << ++cases<< ":" << endl; for (i=0;i<M;++i) { Point p; cin>>p.x>>p.y; pc.x = Max,pc.y = p.y; if (IsonEdge(p,pointVect)) { cout<<"Within"<<endl; continue; } else if (isInside(p,pointVect)) { cout<<"Within"<<endl; } else { cout<<"Outside"<<endl; } } } return 0;}