#include <bits/stdc++.h>
#define int long long
#define f first
#define s second
#define pb push_back
#define endl "\n"
#define SORT(v) sort(begin(v), end(v))
using namespace std;
int32_t main(){ ios::sync_with_stdio(false);cin.tie(0);
int q,n;cin >> q >> n;
int x; cin >> x;
vector<int> v(n + 1,0);
vector<int> a(n + 1,0);
for(int i = 0;i<x;i++){
int z;cin >> z;
v[z] = 1;
}
vector<vector<int>> p(q);
vector<int> yes;
for(int j = 0;j<q;j++){
int b;cin >> b;
bool d = true;
for(int i = 0;i<b;i++){
int student;cin >> student;
p[j].pb(student);
if(!v[student]) d = false;
}
if(d){
for(int i = 0;i<b;i++){
a[p[j][i]]++;
}
}
}
vector<int> ans;
for(int j = 0;j<q;j++){
bool d = true;
int b = p[j].size();
for(int i = 0;i<b;i++){
if(!v[p[j][i]] and a[p[j][i]] > 1) d = false;
}
if(d){
ans.pb(j+1);
}
}
cout << ans.size() << endl;
if(ans.size()){
for(int i : ans) cout << i << " ";
}
}
Copy