#include //#include #include using namespace std; int n ; int m ; void readinput() { //read input data cin >> n; string gods[n] ; int gln[n]; char a[255]; for (int i = 0; i < n; i++) { cin >> gods[i]; gln[i]=gods[i].length(); } cin >> m; int co = 0; for (int i = 0; i < m; i++) { cin >> a; int l = strlen(a); for (int j = 0; j < n; j++) { if (l <= gln[j]) { if( gods[j].find(a) != string::npos) { co++; } } } cout << co << "\n"; co = 0; } } int main() { freopen("wordstone.in", "r", stdin); freopen("wordstone.out", "w", stdout); readinput(); return 0; }