#include #include #include #include using namespace std; const long double pi=3.1415926535897932384626433832795; const long double eps=1e-9; const int INF=(1<<30)-1; const int N=510; const int M=N*N; int n,m,e; int lnk[N],nex[M],nd[M],qu[N],vis[N],unable[N]; struct point{ int x,y; point (int x=0,int y=0):x(x),y(y){} point operator -(point b){ return point(x-b.x,y-b.y); } int operator *(point b){ return x*b.y-y*b.x; } }p[N],q[N]; struct query{ int id,ty; long double d; bool operator <(const query &b)const{return d=L) return que[R].d-que[L].d; else return que[R].d+pi*2-que[L].d; } bool gin(long double x,long double L,long double R){ if (R+eps>=L) return (x+eps>=L) && (x<=R+eps); else return (x+eps>=L) || (x<=R+eps); } void add(int u,int v){ nd[++e]=v; nex[e]=lnk[u]; lnk[u]=e; //printf("Ad %d %d\n",u,v); } int main(){ //freopen("hehe.in","r",stdin); //freopen("h0.out","w",stdout); //freopen("data.in","r",stdin); while (scanf("%d",&n)!=EOF){ e=0; memset(lnk,0,sizeof(lnk)); memset(unable,0,sizeof(unable)); for (int i=1; i<=n; i++) scanf("%d%d",&p[i].x,&p[i].y); scanf("%d",&m); for (int i=1; i<=m; i++) scanf("%d%d",&q[i].x,&q[i].y); /*if (n==1){ bool can=0; for (int i=1; i<=m; i++) if(q[i].x==p[1].x && q[i].y==p[1].y) can=1; if (can) printf("%d\n",m-1); else puts("ToT"); continue; }*/ for (int i=1; i=0; j--) if (que[j].ty) {R=j; break;} if (L==-1){add(i,i);continue;} if (get(L,R)>pi+eps){ int finish=R; for (int j=L+1; j<=finish; j++) if (que[j].ty){ R=L; L=j; if (get(L,R)<=pi+eps) break; } } if (get(L,R)>pi+eps) continue; //printf("%d %d %d\n",i,L,R); //for (int j=0; jpi+eps) zl-=2*pi; if (zr>pi+eps) zr-=2*pi; for (int j=0; j