const Debug = function () {
    const stdin = function (text) {
        return `8 5
        1 2 3 4 5 6 7 10
        3 0
        4 0
        1 2
        1 3
        5 6
        `.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;

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;
}
p.map(x => {
    x.sort();
    n = n.filter(y => x.indexOf(y) < 0);
    x.index = x[0];
    x.cost = x.map(y => cost[y]);
});
n.map(x => {
    var r = [x];
    r.index = x;
    r.cost = [cost[x]];
    p.push(r);
});

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

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