#include <bits/stdc++.h>
using namespace std;

using ll=long long;
#define int ll

#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=a;i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#ifdef LOCAL
#define dmp(x) cerr<<__LINE__<<" "<<#x<<" "<<x<<endl
#else
#define dmp(x) void(0)
#endif

template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(a>b)a=b;}

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

template<class t,class u>
ostream& operator<<(ostream& os,const pair<t,u>& p){
	return os<<"{"<<p.a<<","<<p.b<<"}";
}

template<class t> ostream& operator<<(ostream& os,const vc<t>& v){
	os<<"{";
	for(auto e:v)os<<e<<",";
	return os<<"}";
}

template<class d>
struct maxflow{
	struct E{
		int to,rev;
		d cap;
	};
	vvc<E> g;
	vi itr,lv;
	maxflow(int n):g(n),itr(n),lv(n){}
	void ae(int s,int t,d c){
		g[s].pb({t,(int)g[t].size(),c});
		g[t].pb({s,(int)g[s].size()-1,0});
	}
	void bfs(int s){
		fill(all(lv),-1);
		lv[s]=0;
		queue<int> q;
		q.push(s);
		while(q.size()){
			int v=q.front();q.pop();
			for(auto e:g[v])if(e.cap>0&&lv[e.to]==-1){
				lv[e.to]=lv[v]+1;
				q.push(e.to);
			}
		}
	}
	d dfs(int v,int t,d f){
		if(v==t)return f;
		d res=0;
		for(int&i=itr[v];i<(int)g[v].size();i++){
			E& e=g[v][i];
			if(e.cap>0&&lv[e.to]==lv[v]+1){
				d a=dfs(e.to,t,min(f,e.cap));
				if(a>0){
					e.cap-=a;
					g[e.to][e.rev].cap+=a;
					res+=a;
					f-=a;
					if(f<=0)break;
				}
			}
		}
		return res;
	}
	d calc(int s,int t){
		d f=0;
		while(1){
			bfs(s);
			if(lv[t]==-1)
				return f;
			fill(all(itr),0);
			f+=dfs(s,t,1e9);
		}
	}
};

using ld=long double;
using cm=complex<ld>;
#define x real()
#define y imag()
const ld eps=1e-8;
const ld PI=acos(ld(-1));
int sgn(ld a){return a<-eps?-1:(a>eps?1:0);}
ld dot(cm a,cm b){return a.x*b.x+a.y*b.y;}
ld crs(cm a,cm b){return a.x*b.y-a.y*b.x;}
ld crs(cm a,cm b,cm c){return crs(b-a,c-a);}
int ccw(cm a,cm b){return sgn(crs(a,b));}
int ccw(cm a,cm b,cm c){return ccw(b-a,c-a);}

using cr=pair<cm,ld>;
//AOJ2423
cr circumc(cm a,cm b,cm c){
	b-=a;
	c-=a;
	cm r=norm(b)*c-norm(c)*b;
	r=cm(r.y,-r.x)/(2*crs(b,c));
	return cr(a+r,abs(r));
}
//AOJ2423
cr mindisc(const vc<cm>& p,array<cm,3> q,int i,int j){
	if(i==int(p.size())){
		if(j==0)
			return {{0,0},-1};
		else if(j==1)
			return {q[0],0};
		else if(j==2)
			return {(q[0]+q[1])*ld(0.5),abs(q[0]-q[1])/2};
		else if(j==3)
			return circumc(q[0],q[1],q[2]);
		else
			assert(false);
	}
	cr c=mindisc(p,q,i+1,j);
	if(sgn(abs(c.a-p[i])-c.b)==1){
		assert(j<3);
		q[j]=p[i];
		return mindisc(p,q,i+1,j+1);
	}else
		return c;
}
cr mindisc(vc<cm> p){
	shuffle(all(p),mt19937());
	return mindisc(p,array<cm,3>(),0,0);
}

signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
	
	int n,m;cin>>n>>m;
	vc<ld> r(n);
	rep(i,n)cin>>r[i];
	vc<ld> p(m);
	rep(i,m){
		int k;cin>>k;
		vc<cm> a;
		rep(j,k){
			ld s,t;
			cin>>s>>t;
			a.eb(s,t);
		}
		p[i]=mindisc(a).b;
	}
	
	int s=1+m+n+1;
	vc<bool> used(n);
	vi ans(m,-1);
	rep(i,m){
		rep(j,n)if(sgn(p[i]-r[j])<=0&&!used[j]){
			used[j]=1;
			maxflow<int> mf(s);
			rng(k,i+1,m){
				mf.ae(0,1+k,1);
				rep(l,n)if(sgn(p[k]-r[l])<=0&&!used[l])
					mf.ae(1+k,1+m+l,1);
			}
			rep(k,n)if(!used[k])
				mf.ae(1+m+k,s-1,1);
			if(mf.calc(0,s-1)==m-1-i){
				ans[i]=j;
				break;
			}
			used[j]=0;
		}
		if(ans[i]==-1){
			cout<<"NG"<<endl;
			return 0;
		}
	}
	for(auto v:ans)
		cout<<v+1<<endl;
}



Measured memory_bytes: 3520