Problem: G: Code Art Online

Code Art Online (CAO) is an online RPG that advances adventures by solving various problems by programming. Since CAO was the world's first game that realized a virtual reality space, it was sold out while it was very popular, and users who purchased the game should enjoy this world. However, players who dive into the game are told a terrifying decree by the gamemaster.

"Unless some of you players solve the last problem of the last dungeon, you can't get out of this virtual space. And in this world, WA and TLE / RE mean death in the real world. I want you to start the problem with your heart. "

You are one of the CAO players, and you are doing your best to capture the game in order to clear this game and return to the real world. One day, you face the following problems.

This time, a party was formed with n members to capture the new dungeon. You are one of the parties. In order to enter the dungeon that you are about to capture, you must pass through a hole that can be seen from the cliff. If you can pass through the hole safely, you can enter the dungeon, but if you can not enter the hole and touch other parts, death is waiting. Furthermore, if someone passes through one hole, that hole will close, so each person must enter a separate hole.

Holes and people are considered on a two-dimensional plane. The shape of the hole is a circle of various sizes, as shown in Fig. G-1. In the input, the length of the radius is given.

<image>
---
Figure G-1: Hole shape

As shown in Fig. G-2, the human shape is given as a polygonal cross section of the human (not necessarily convex). In the input, the vertices are given counterclockwise to represent the shape of the polygon. It can be assumed that any three points of a polygon do not line up on a straight line. Furthermore, it is assumed that polygonal line segments do not intersect each other except for the purpose of forming vertices. It may rotate freely to pass through the hole (however, rotation in the z-axis direction is prohibited). It is assumed that the vertices of a polygon representing a person can pass through the hole even if it is on the circumference of the hole.

<image>
---
Figure G-2: Human shape

You, who have the highest algorithm skills in the party, decided to solve the decision problem of whether everyone can pass through the hole safely. If you can pass it safely, indicate who should pass which hole.

* You will not die in this contest, but if you make a mistake, please solve it with the intention of dying.

Input

On the first line, the integer n (1 <= n <= 100), which represents the number of holes, and the integer m (1 <= m <= n), which represents the number of parties, are entered separated by spaces.

In the next line, n integers ri (1 <= ri <= 1000) representing the radius of the hole are entered, separated by spaces. These holes are counted as the 1st hole, the 2nd hole, ..., and the nth hole in the order of input.

Then, information on the shape of m people is input. For the information of one person, the number of vertices p (3 <= p <= 100) of the polygon is first input to the first line. In the following line p, the coordinates of the vertices of the polygon are given counterclockwise. Integers xi, yi (-1000 <= xi, yi <= 1000) representing one vertex are entered in each line, separated by spaces. People are counted as the 1st person, the 2nd person, ..., and the mth person in the order of input.

Output

Output the number of hole that the person with i (1 <= i <= m) should enter. On the i-line, output the number of the hole that the person i should pass through.

If there are multiple paths, output the smallest path in lexicographical order. When there are two sequences A = {a1, a2, ..., am} and B = {b1, b2, ..., bm}, if A is smaller than B in lexicographical order, ai is bi. For the first i that is different, we say when ai is smaller than bi.

If no way is found, output one line as "NG". Don't forget to print a newline at the end.

Sample Input 1


3 3
25 100 10
8
-10 0
-twenty two
0 10
twenty two
10 0
twenty two
0 -10
-twenty two
Four
30 0
50 0
50 40
30 40
3
30 -10
45 -70
60 -10


Sample Output 1


3
1
2


Sample Input 2


4 3
25 15 15 30
Five
0 0
10 0
20 10
0 20
-20 10
3
20 0
40 0
30 10
3
-50 0
-30 0
-40 10


Sample Output 2


1
2
3


Sample Input 3


twenty two
1 30
Four
0 0
10 0
10 10
0 10
3
5 5
20 20
5 20


Sample Output 3


NG






Example

Input

3 3
25 100 10
8
-10 0
-2 2
0 10
2 2
10 0
2 -2
0 -10
-2 -2
4
30 0
50 0
50 40
30 40
3
30 -10
45 -70
60 -10


Output

3
1
2

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
using namespace std;
typedef long long LL;

typedef complex<double> P;
const double EPS = 1e-8;

struct C{P p;double r;};

// 点集合 ps をすべて含む円のうち，半径最小の円を求める
C smallest_circle(const vector<P>& ps) {
    const double init = 1.0;
    const double rate = 0.99; // 1e-9 ~ (0.99^2000)
    if(ps.empty()) return {{0, 0}, 0};
    double T = init;
    P cur;
    while(T > EPS) {
        P to = ps.front();
        for(P p : ps) if(abs(to - cur) < abs(p - cur)) {
            to = p;
        }
        cur += (to - cur) * T;
        T *= rate;
    }
    double r = 0;
    for(P p : ps) {
        r = max(r, abs(p - cur));
    }
    return {cur, r};
}

struct BipartiteMatching{
    typedef vector<int> Node;
    typedef vector<Node> Graph;

    Graph G;
    vector<int> match;
    vector<bool> used;

    BipartiteMatching(int N) : G(N) {}

    void add_edge(int u, int v){
        G[u].push_back(v);
        G[v].push_back(u);
    }

    bool dfs(int u){
        used[u] = true;
        for(int v : G[u]){
            int w = match[v];
            if(w < 0 || (!used[w] && dfs(w))){
                match[u] = v;
                match[v] = u;
                return true;
            }
        }
        return false;
    }

    int matching(){
        int res = 0;
        match.assign(G.size(), -1);
        for(int u = 0; u < G.size(); u++){
            if(match[u] < 0){
                used.assign(G.size(), false);
                if(dfs(u)) res++;
            }
        }
        return res;
    }
};

int main(){
    int n, m;
    while(cin >> n >> m) {
        vector<double> R(n);
        REP(i, n) cin >> R[i];

        vector<double> T(m);
        REP(k, m) {
            int q;
            cin >> q;
            vector<P> ps(q);
            REP(i, q) {
                double x, y;
                cin >> x >> y;
                ps[i] = {x, y};
            }
            auto c = smallest_circle(ps);
            T[k] = c.r;
        }

        // T -> R (m -> n)
        vector<int> res;
        vector<bool> used(n);
        for(int i = 0; i < m; i++) {
            for(int k = 0; k < n; k++) {
                if(used[k]) continue;
                if(!(T[i] <= R[k] + EPS * 1e4)) continue;
                BipartiteMatching bp(m + n);
                for(int j = i + 1; j < m; j++) {
                    for(int l = 0; l < n; l++) {
                        if(used[l]) continue;
                        if(l == k) continue;
                        if(T[j] <= R[l] + EPS * 1e4) {
                            bp.add_edge(j, l + m);
                        }
                    }
                }
                int mc = i + 1 + bp.matching();
                if(mc == m) {
                    res.push_back(k + 1);
                    used[k] = true;
                    break;
                }
            }
            if(res.size() != i + 1) break;
        }

        if(res.size() == m) {
            for(int a : res) {
                cout << a << endl;
            }
        } else {
            cout << "NG" << endl;
        }
    }
    return 0;
}