#include<cmath>
#include<cstdio>
#include<vector>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

const double EPS=1e-8;

template<class T>
struct point{
	T x,y;
	point operator+(const point &a)const{ return (point){x+a.x,y+a.y}; }
	point operator-(const point &a)const{ return (point){x-a.x,y-a.y}; }
};

template<class T>
point<T> operator*(T c,const point<T> &a){ return (point<T>){c*a.x,c*a.y}; }

template<class T>
point<double> operator/(const point<T> &a,double c){
	return (point<double>){a.x/c,a.y/c};
}

template<class T>
struct polygon:vector< point<T> >{};

template<class T>
struct circle{
	point<T> c;
	T r;
};

template<class T>
double abs(const point<T> &a){ return sqrt(a.x*a.x+a.y*a.y); }

template<class T>
double dist(const point<T> &a,const point<T> &b){
	return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}

vector< circle<double> > kirito(const point<double> &p,const point<double> &q,double r){
	double d=abs(q-p)/2;
	vector< circle<double> > res;
	if(r-EPS<d && d<r+EPS){
		res.push_back((circle<double>){(p+q)/2,r});
	}
	else if(EPS<d && d<r){
		point<double> a=(q-p)/2;
		point<double> b=sqrt(r*r-d*d)/d*a;
		res.push_back((circle<double>){p+a+(point<double>){b.y,-b.x},r});
		res.push_back((circle<double>){p+a-(point<double>){b.y,-b.x},r});
	}
	return res;
}

bool cover(const circle<double> &C,const point<double> &p){
	return dist(C.c,p)<C.r+EPS;
}

bool cover(const circle<double> &C,const polygon<double> &G){
	int n=G.size();
	rep(i,n) if(!cover(C,G[i])) return false;
	return true;
}

bool can_though(polygon<double> F,double r){
	int n=F.size();
	rep(i,n) rep(j,i) {
		vector< circle<double> > C=kirito(F[i],F[j],r);
		rep(k,C.size()){
			if(cover(C[k],F)) return true;
		}
	}
	return false;
}

const int V_MAX=100;

bool augment(int u,bool *vis,int match[2][V_MAX],const vector<int> *G){
	if(u==-1) return true;

	rep(i,G[u].size()){
		int v=G[u][i];
		if(!vis[v]){
			vis[v]=true;
			if(augment(match[1][v],vis,match,G)){
				match[0][u]=v;
				match[1][v]=u;
				return true;
			}
		}
	}
	return false;
}

int match[2][V_MAX];
int asuna(int L,int R,const vector<int> *G){
	rep(u,L) match[0][u]=-1;
	rep(v,R) match[1][v]=-1;

	int res=0;
	static bool vis[V_MAX];
	rep(u,L){
		rep(v,R) vis[v]=false;
		if(augment(u,vis,match,G)) res++;
	}
	return res;
}

int main(){
	int n,m; scanf("%d%d",&n,&m);
	int r[100];
	rep(i,n) scanf("%d",r+i);

	polygon<double> man[100];
	rep(i,m){
		int k; scanf("%d",&k);
		man[i].resize(k);
		rep(j,k) scanf("%lf%lf",&man[i][j].x,&man[i][j].y);
	}

	bool adj[V_MAX][V_MAX]; // 隣接行列
	rep(u,m) rep(v,n) adj[u][v]=can_though(man[u],r[v]);

	vector<int> G[V_MAX];
	rep(u,m) rep(v,n) if(adj[u][v]) G[u].push_back(v);

	if(asuna(m,n,G)<m){ puts("NG"); return 0; }

	int ans[100];
	bool matched[100]={};
	rep(u0,m){
		rep(v0,n) if(adj[u0][v0] && !matched[v0]) {
			matched[v0]=true;

			rep(u,m) G[u].clear();
			for(int u=u0+1;u<m;u++) rep(v,n) if(adj[u][v] && !matched[v]) G[u].push_back(v);

			if(asuna(m,n,G)==m-u0-1){
				ans[u0]=v0;
				break;
			}

			matched[v0]=false;
		}
	}
	rep(u,m) printf("%d\n",ans[u]+1);

	return 0;
}