#include <iostream>
#include <fstream>
#include <bitset>
using namespace std;
ifstream in("aprindere.in");
ofstream out("aprindere.out");
const int NMAX = 1000;
int n, m, res;
bitset <1 + NMAX> ap;
int main()
{
in >> n >> m;
for(int i = 0; i < n; i++) {
int light;
in >> light;
ap[i] = light;
}
for(int i = 1; i <= m; i++) {
int room, time, no;
in >> room >> time >> no;
if(ap[room] == 0) {
res += time;
for(int j = 1; j <= no; j++) {
int x;
in >> x;
ap[x] = 1 - ap[x];
}
} else {
for(int j = 1; j <= no; j++) {
int x;
in >> x;
}
}
}
out << res << '\n';
in.close();
out.close();
return 0;
}