#include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

const double EPS = 1.0e-10;

int bipartiteMaximumMatchings(const vector<vector<bool> >& graph)
{
    int ret = 0;
    int n = graph.size();
    int m = graph[0].size();
    vector<int> selectN(n, -1);
    vector<int> selectM(m, -1);

    for(int i=0; i<n; ++i){
        vector<bool> visitedN(n, false);
        vector<bool> visitedM(m, false);
        visitedN[i] = true;
        vector<int> path(min(n,m)*2, -1);

        path[0] = i;
        int index = 1;
        for(;;){
            while(++path[index] < m && (!graph[path[index-1]][path[index]] || selectN[path[index-1]]==path[index] || visitedM[path[index]]));
            if(path[index] < m){
                if(selectM[path[index]] == -1){
                    for(int j=0; j<index; j+=2){
                        selectN[path[j]] = path[j+1];
                        selectM[path[j+1]] = path[j];
                    }
                    ++ ret;
                    break;
                }
                if(!visitedN[selectM[path[index]]]){
                    path[index+1] = selectM[path[index]];
                    visitedM[path[index]] = true;
                    visitedN[path[index+1]] = true;
                    index += 2;
                }
            }
            else{
                path[index] = -1;
                index -= 2;
                if(index < 0)
                    break;
            }
        }

        if(ret == m)
            break;
    }

    return ret;
}

class Point
{
public:
    double y, x;
    Point(){
        y = x = 0.0;
    }
    Point(double y0, double x0){
        y = y0;
        x = x0;
    }
    Point operator+(const Point& p) const{
        return Point(y + p.y, x + p.x);
    }
    Point operator-(const Point& p) const{
        return Point(y - p.y, x - p.x);
    }
    Point operator*(double a) const{
        return Point(y * a, x * a);
    }
    Point operator/(double a) const{
        return Point(y / a, x / a);
    }
    double length() const{
        return sqrt(y * y + x * x);
    }
    double dist(const Point& p) const{
        return sqrt(pow(y - p.y, 2) + pow(x - p.x, 2));
    }
    double dot(const Point& p) const{
        return y * p.y + x * p.x; // |a|*|b|*cos慮
    }
    double cross(const Point& p) const{
        return x * p.y - y * p.x; // |a|*|b|*sin慮
    }
};

int circlesIntersection(const Point& p1, double r1, const Point& p2, double r2, vector<Point>& intersection)
{
    double y = p2.y - p1.y;
    double x = p2.x - p1.x;
    double a = (y*y + x*x + r1*r1 - r2*r2) / 2;
    double b = (y*y + x*x) * r1*r1 - a*a;

    if(y*y + x*x < EPS || b < -EPS){
        intersection.resize(0);
        return 0;
    }
    if(b < EPS){
        intersection.assign(1, Point(y, x) * (a / (y*y + x*x)) + p1);
        return 1;
    }

    intersection.assign(2, Point(x, -y) * sqrt(b));
    intersection[1] = intersection[1] * -1;
    for(int i=0; i<2; ++i)
        intersection[i] = (intersection[i] + Point(y, x) * a) / (y*y + x*x) + p1;
    return 2;
}

bool check(double r, const vector<Point>& p)
{
    int n = p.size();
    for(int i=0; i<n; ++i){
        for(int j=0; j<i; ++j){
            vector<Point> intersection;
            circlesIntersection(p[i], r, p[j], r, intersection);

            for(unsigned k=0; k<intersection.size(); ++k){
                bool ok = true;
                for(int l=0; l<n; ++l){
                    if(intersection[k].dist(p[l]) > r + EPS){
                        ok = false;
                        break;
                    }
                }
                if(ok)
                    return true;
            }
        }
    }

    return false;
}

int main()
{
    int n, m;
    cin >> n >> m;

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

    vector<vector<Point> > p(m);
    for(int i=0; i<m; ++i){
        int a;
        cin >> a;
        p[i].resize(a);
        for(int j=0; j<a; ++j)
            cin >> p[i][j].x >> p[i][j].y;
    }

    vector<vector<bool> > through(m, vector<bool>(n));
    for(int i=0; i<n; ++i){
        for(int j=0; j<m; ++j){
            through[j][i] = check(r[i], p[j]);
        }
    }

    vector<int> ret(m, -1);
    for(int i=0; i<m; ++i){
        for(int j=0; j<n; ++j){
            if(!through[i][j])
                continue;

            vector<bool> tmp(n, false);
            tmp[j] = true;
            swap(through[i], tmp);
            if(bipartiteMaximumMatchings(through) == m){
                ret[i] = j;
                break;
            }
            swap(through[i], tmp);
        }
        if(ret[i] == -1){
            cout << "NG" << endl;
            return 0;
        }
    }

    for(int i=0; i<m; ++i)
        cout << (ret[i] + 1) << endl;

    return 0;
}

Measured memory_bytes: 1352