#include #include using namespace std; int main() { int n,i,j; cin>>n; string s[n],z; for(i=0;i>s[i]; int p[n]; for(i=0;i>p[i]; int d; cin>>d; int h[d],f,l,u[d]; for(i=0;i>f>>l>>z; for(j=f;j<=l;j++) { if (z.find(s[j]) == string::npos) { h[i]=h[i]+p[j]; } } } sort(h,h+d); cout<