#include <bits/stdc++.h> #define ll long long using namespace std; int main() { int m,n,o1,o2,k,count=0,count2=0,num=0; string str; cin>>m>>n; int a[10000]={0}; int h[100]={0}; for(int i=0;i<n;i++){ cin>>o1; a[o1]=1; } //map<int,map<string,int>> map1; for(int i=0;i<m;i++) { cin>>str>>k; for(int j=0;j<k;j++) { cin>>o2; if(a[o2]){ h[num++] = o2; count++; } } if(num) { count2++; cout<<str<<": "; printf("%04d",h[0]); for(int j=1;j<num;j++){ printf(" %04d",h[j]); } num=0; cout<<endl; } } cout<<count2<<" "<<count<<endl; return 0; }