@SuppressWarnings("unchecked")
	void run(){
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt(); m = sc.nextInt();
		int[] r = new int[n];
		for(int i=0;i<n;i++)r[i]=sc.nextInt();
		list = new List[m];
		e = new boolean[m][n];
		for(int i=0;i<m;i++){
			list[i] = new ArrayList<R>();
			int k = sc.nextInt();
			double[][] p = new double[k][2];
			for(int j=0;j<k;j++)for(int f=0;f<2;f++)p[j][f] = sc.nextInt();
			double[] c = smallestCircle(p);
			double R = 0;
			for(int j=0;j<k;j++)R = Math.max(R, norm(c, p[j]));
			R = Math.sqrt(R);
			for(int j=0;j<n;j++)if(R < r[j]+1e-6){
				e[i][j] = true;
				list[i].add(new R(j, r[j]));
			}
			Collections.sort(list[i]);
		}
		res = new int[m];
		u = new boolean[n];
		f(0);
		if(ok)for(int x:res)System.out.println(x+1);
		else System.out.println("NG");
	}