#include <iostream>
#include <complex>
#include <vector>
#include <cstdio>
#include <cstring>
#include <climits>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <list>
using namespace std;

typedef long long ll;

#define MAX 250
#define dim 2
#define EPS (1e-6)
#define INF 999999

typedef complex<double> P;

class Edge{
public:
  int to, cap, rev;

  Edge(){}
  Edge(int _to,int _cap,int _rev){
    to = _to;
    cap = _cap;
    rev = _rev;
  }
};

double dist2(const P &a, const P &b){
  double x = a.real() - b.real();
  double y = a.imag() - b.imag();
  return x * x + y * y;
}

double dot(const P &a, const P &b){
  return real(conj(a) * b);
}

struct min_ball{
  P center;
  double radius2;

  void add(const P &p){
    ps.push_back(p);
  }

  void compile(){
    m = 0;
    center = P(0, 0);
    radius2 = -1;
    make_ball(ps.end());
  }

  template <class OUT>

  void support(OUT out){
    copy(ps.begin(), supp_end, out);
  }

  min_ball(){
    for(int i = 0; i <= dim; i++){
      c[i] = P(0, 0);
      v[i] = P(0, 0);
    }
  }

private:
  list<P> ps;
  list<P>::iterator supp_end;
  int m;
  P v[dim + 1], c[dim + 1];
  double z[dim + 1], r[dim + 1];

  void pop() { m--; };

  void push(const P &p){
    if(m == 0){
      c[0] = p;
      r[0] = 0;
    }
    else{
      double e = dist2(p, c[m - 1]) - r[m - 1];
      P delta = p - c[0];
      v[m] = p - c[0];

      for(int i = 1; i < m; i++){
	v[m] -= v[i] * dot(v[i], delta) / z[i];
      }

      z[m] = dot(v[m], v[m]);
      c[m] = c[m - 1] + e * v[m] / z[m] / 2.0;
      r[m] = r[m - 1] + e * e / z[m] / 4.0;
    }

    center = c[m];
    radius2 = r[m];
    m++;
  }

  void make_ball(list<P>::iterator i){
    supp_end = ps.begin();
    if(m == dim + 1) return;
    for(list<P>::iterator k = ps.begin(); k != i; ){
      list<P>::iterator j = k++;
      if(dist2(*j, center) > radius2){
	push(*j);
	make_ball(j);
	pop();
	move_to_front(j);
      }
    }
  }

  void move_to_front(list<P>::iterator j){
    if(supp_end == j) supp_end++;
    ps.splice(ps.begin(), ps, j);
  }
};

int n, m;
int cap[MAX][MAX], cap_tmp[MAX][MAX];
bool used[MAX];

int dfs(int v, int t, int f){
  if(v == t) return f;

  used[v] = true;

  for(int i = 0; i < n + m + 2; i++){
    int c = cap[v][i];

    if(!used[i] && c > 0){
      int d = dfs(i , t , min(f, c));

      if(d > 0){
        cap[v][i] -= d;
        cap[i][v] += d;
        return d;
      }
    }
  }

  return 0;
}

int mf(int s, int t){
  int flow = 0;

  for(;;){
    memset(used, 0, sizeof(used));
    int f = dfs(s, t, INF);
    if(f == 0) return flow;
    flow += f;
  }
}

void showRadius(int m, double *r){
  for(int i = 0; i < m; i++){
    printf("%.2f ", r[i]);
  }
  cout<<endl;
}

void copyCap(int from[MAX][MAX], int to[MAX][MAX]){
  for(int i = 0; i < n + m + 2; i++){
    for(int j = 0; j < n + m + 2; j++){
      to[i][j] = from[i][j];
    }
  }
}

int main(){
  srand((unsigned)time(NULL));

  while(cin >> n >> m){
    double r[102];

    for(int i = 0; i < n; i++){
      cin >> r[i];
    }

    vector<P> pol[102];
    double pol_r[102];

    for(int i = 0; i < m; i++){
      int pi;
      cin >> pi;

      struct min_ball ball;

      for(int j = 0; j < pi; j++){
	P p;
	cin >> p.real() >> p.imag();
	pol[i].push_back(p);
	ball.add(p);
      }

      ball.compile();
      pol_r[i] = sqrt(ball.radius2);
    }

    memset(cap, 0, sizeof(cap));

    for(int i = 0; i < m; i++){
      for(int j = 0; j < n; j++){
	if(pol_r[i] < r[j] + EPS){
	  cap[i][j + m] = 1;
	}
      }
    }

    for(int i = 0; i < m; i++){
      cap[n + m][i] = 1;
    }
    for(int i = 0; i < n; i++){
      cap[i + m][n + m + 1] = 1;
    }

    copyCap(cap, cap_tmp);

    int f = mf(n + m, n + m + 1);

    copyCap(cap_tmp, cap);

    if(f == m){
      int ans[m];
      memset(ans, -1, sizeof(ans));

      for(int i = 0; i < m; i++){
	int now = m - i - 1;

	for(int j = 0; j < n; j++){
	  if(cap[i][j + m] <= 0) continue;

	  cap[i][j + m] = 0;
	  cap[n + m][i] = 0;
	  cap[j + m][n + m + 1] = 0;

	  f = mf(n + m, n + m + 1);
	  copyCap(cap_tmp, cap);

	  if(f == now){
	    ans[i] = j + 1;

	    for(int k = 0; k < n + m + 2; k++){
	      cap[i][k] = cap[k][i] = 0;
	      cap[j + m][k] = cap[k][j + m] = 0;
	    }

	    copyCap(cap, cap_tmp);

	    break;
	  }
	}
      }

      for(int i = 0; i < m; i++){
	cout << ans[i] << endl;
      }
    }
    else{
      cout << "NG\n";
    }
  }
}

Measured memory_bytes: 1832