const Debug = function () {
    const stdin = function (text) {
        return `11 6
        1 2 3 4 5 6 7 10 1 3 12
        3 0
        4 0
        1 2
        1 3
        5 6
        7 8
        `.replace(/^\s+/g, '').replace(/^\n$/, '');
    };

    return stdin;
};


const Release = function () {
    const fs = require('fs');
    const stdin = function (text) {
        if (text) console.log(text);
        return fs.readFileSync('/dev/stdin', 'utf8');
    }
    return stdin;
};


const debug = false;

const stdin = debug ? Debug() : Release();
const input = stdin().split('\n');

const NM = input[0].split(' ').map(x => parseInt(x));
const cost = input[1].split(' ').filter(x => x).map(x => parseInt(x));
const p = new Array(NM[1]);
for (var i = 0; i < p.length; i++) p[i] = input[2 + i].split(' ').filter(x => x).map(x => parseInt(x)).sort();

var n = new Array(NM[0]);
for (var i = 0; i < n.length; i++) n[i] = i;

var pp = [];
while (true) {
    if (p.length <= 1) break;
    /*
        var h = false;
        for (var i = 1; i < p.length; i++) {
            for (var j = 0; j < i; j++) {
                var u = p[i].concat(p[j]);
                var v = u.filter((x, i, a) => i === a.indexOf(x));
                if (u.length > v.length) {
                    p[j] = v;
                    p.splice(i, 1);
                    h = true;
                    break;
                }
            }
            if (h) break;
        }
        if (!h) break;
        */

    var q = p.pop();
    var h = false;
    for (var i = 0; i < p.length; i++) {
        var t = p[i];
        for (var j = 0; j < q.length; j++) {
            if (t.indexOf(q[j]) >= 0) {
                q.filter(x => t.indexOf(x) < 0).map(x => t.push(x));
                h = true;
                break;
            }
        }
        if (h) break;
    }
    if (!h) {
        pp.push(q);
    }
}
var costArray = new Array(p.length + pp.length);
var zz = 0;
var sum = 0;
var count = 0;
for (var i = 0; i < p.length; i++) costArray[zz++] = p[i].map(x => cost[x]).sort();
for (var i = 0; i < pp.length; i++) costArray[zz++] = pp[i].map(x => cost[x]).sort();
// console.log(costArray);
// console.log(p);
// console.log(pp);

for (var i = 0; i < NM[0]; i++) {
    var h = false;
//    console.log('---');
//    console.log(i);
    for (var j = 0; j < p.length; j++) {
        if (p[j].indexOf(i) >= 0) {
//            console.log(p[j]);
            h = true;
            break;
        }
    }
    if (h) continue;
    h = false;
    for (var j = 0; j < pp.length; j++) {
        if (pp[j].indexOf(i) >= 0) {
//            console.log(pp[j]);
            h = true;
            break;
        }
    }
    if (h) continue;
    sum += cost[i];
    count++;
}

// console.log(sum);
// console.log(count);

var q = [];
costArray.map(x => {
    sum += x.splice(0, 1)[0];
    q = q.concat(x.splice(0, costArray.length));
});
count += costArray.length;
var z = (count - 1) * 2 - count;
for (var i = 0; i < z; i++) sum += q[i];

if (count <= 1) console.log(0);
else console.log(isNaN(sum) ? 'Impossible' : sum);