#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vl;
typedef pair<ll, ll> pl;
typedef long double ld;
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define max(a, b) (a>b ? a : b)
#define min(a, b) (a<b ? a : b)
#define FAST ios::sync_with_stdio(0), cin.tie(0),cout.tie(0)
const int N = int(1e6) + 3;
const int MOD = int(1e9) + 7;
int n,m;
int q, a[N];
int w[N],x;
vector<int> p[N];
int cnt[N];
set<int> ss;
int main() {
FAST;
//freopen("easy", "r", stdin);
cin >> n >> m;
cin >> q;
for(int i=0;i<q;i++){
cin >> x;
a[x]=1;
}
for(int i=0;i<m;i++){
cin >>w[i];
for(int j=0;j<w[i];j++){
cin >> x;
if(a[x]==0)
continue;
p[i].pb(x);
cnt[x]++;
}
}
for(int i=0;i<m;i++){
if(p[i].size()!=w[i]){
for(auto u:p[i]){
cnt[u]--;
}
}
}
for(int i=0;i<m;i++){
if(p[i].size()==w[i]){
for(auto u:p[i]){
if(cnt[u]==1){
ss.insert(i);
}
}
}
}
cout << ss.size() << endl;
for(auto u:ss){
cout << u+1 << endl;
}
return 0;
}
Copy