#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> k(m), p(m);
  vector<vector<int>> s(m, vector<int>(n));
  for (int i = (0); i < (int)(m); i++) {
    cin >> k[i];
    for (int j = (0); j < (int)(k[i]); j++) cin >> s[i][j];
  }
  for (int i = (0); i < (int)(m); i++) cin >> p[i];
}
