#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#define maxl 110
#define eps 1e-8
using namespace std;
inline int sgn(double x)
{
if(x>-eps && x<eps) return 0;
if(x<0) return -1;
else return 1;
}
struct point
{
double x,y;
point(double a=0,double b=0)
{
x=a;y=b;
}
point operator - (const point &b)const
{
return point(x-b.x,y-b.y);
}
inline double norm()
{
return sqrt(x*x+y*y);
}
};
inline double det(const point &a,const point &b)
{
return a.x*b.y-a.y*b.x;
}
inline double dot(const point &a,const point &b)
{
return a.x*b.x+a.y*b.y;
}
struct line
{
point s,e;
double k;
line(point a=point(),point b=point())
{
s=a;e=b;
k=atan2(e.y-s.y,e.x-s.x);
}
};
inline bool point_on_seg(point &p,line a)
{//在端点处点积为0,此时算在直线上
return sgn(det(p-a.s,p-a.e))==0 && sgn(dot(p-a.s,p-a.e))<=0;
}
struct polygon
{
int n;
point a[maxl];
polygon(){}
inline double perimeter()
{
double sum=0;
a[n+1]=a[1];
for(int i=1;i<=n;i++)
sum+=(a[i+1]-a[i]).norm();
return sum;
}
inline double area()
{
double sum=0;
a[n+1]=a[1];
for(int i=1;i<=n;i++)
sum+=det(a[i+1],a[i]);
return sum/2;
}
inline int point_in(point t)
{//0 out 1 in 2 on
int num=0,d1,d2,k;
a[n+1]=a[1];
for(int i=1;i<=n;i++)
{
if(point_on_seg(t,line(a[i],a[i+1])))
return 2;
k=sgn(det(a[i+1]-a[i],t-a[i]));
d1=sgn(a[i].y-t.y);
d2=sgn(a[i+1].y-t.y);
if(k>0 && d1<=0 && d2>0) num++;
if(k<0 && d2<=0 && d1>0) num++;
}
return num%2!=0;
}
}d;
int n,m,cas;
point a[maxl];
inline void prework()
{
scanf("%d",&m);
d.n=n;
for(int i=1;i<=n;i++)
scanf("%lf%lf",&d.a[i].x,&d.a[i].y);
}
inline void mainwork()
{
++cas;
if(cas>1)
puts("");
printf("Problem %d:\n",cas);
point p;
for(int i=1;i<=m;i++)
{
scanf("%lf%lf",&p.x,&p.y);
if(d.point_in(p)==0)
puts("Outside");
else
puts("Within");
}
}
inline void print()
{
}
int main()
{
while(~scanf("%d",&n) && n)
{
prework();
mainwork();
print();
}
return 0;
}
从这个点做一条水平向右的射线,统计射线与多边形相交的情况,如果相交次数为偶数,则说明点在多边形外,否在就在多边形内