// #pragma GCC optimize(2)
// #pragma GCC optimize(3,"Ofast","inline")
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "D:/OneDrive/study/cpp/.vscode/debug.h"
#else
#define debug(...) 42;
#endif
#define int long long
#define endl "\n"
#define ull unsigned long long
#define ll __int128_t
mt19937 rd(chrono::system_clock::now().time_since_epoch().count());
const int mod = 998244353;
const int inf = 0x3f3f3f3f3f3f3f3f;
const int MAXN = 2e5 + 10;
const double eps = 1e-6;
int n, len, z, q;
string s;
struct hash
{
const int mod_p1 = 1610612741;
const int mod_p2 = 805306457;
const int mod_p3 = 402653189;
const int base_1 = 131;
const int base_2 = 13331;
vector<int> b1, h1;
void init(string s)
{
// s从1开始
int n = (int)s.size() - 1;
b1.assign(n + 1, 0);
// b2.assign(n + 1, 0);
h1.assign(n + 1, 0);
// h2.assign(n + 1, 0);
b1[0] = b2[0] = 1;
for (int i = 1; i <= n; i++)
{
b1[i] = b1[i - 1] * base_1 % mod_p1;
// b2[i] = b2[i - 1] * base_2 % mod_p2;
h1[i] = (h1[i - 1] * base_1 % mod_p1 + s[i] - '0' + 1) % mod_p1;
// h2[i] = (h2[i - 1] * base_2 % mod_p2 + s[i] - '0' + 1) % mod_p2;
}
}
int getHash1(int l, int r)
{
return (h1[r] - (h1[l - 1] * b1[r - l + 1]) % mod_p1 + mod_p1) % mod_p1;
}
// int getHash2(int l, int r)
// {
// return (h2[r] - (h2[l - 1] * b2[r - l + 1]) % mod_p2 + mod_p2) % mod_p2;
// }
} ha[1010];
bool check(int index)
{
int now = 1;
int l = 1, r = len;
for (int i = 1; i <= z; i++)
{
if (now > len)
return 1;
while (l <= r)
{
int mid = (l + r) >> 1;
if (ha[index].getHash1(now, mid) != ha[1005].getHash1(now, mid) /*|| ha[index].getHash2(now, mid) != ha[1005].getHash2(now, mid)*/)
{
r = mid - 1;
}
else
{
l = mid + 1;
}
}
now = l + 1;
l = now;
r = len;
}
if (now > len)
{
return 1;
}
if (ha[index].getHash1(now, len) == ha[1005].getHash1(now, len) /*&& ha[index].getHash2(now, len) == ha[1005].getHash2(now, len)*/)
{
return 1;
}
return 0;
}
void solve()
{
cin >> n >> q >> len >> z;
for (int i = 1; i <= n; i++)
{
cin >> s;
s = ' ' + s;
ha[i].init(s);
}
while (q--)
{
cin >> s;
s = ' ' + s;
ha[1005].init(s);
int ans = 0;
for (int i = 1; i <= n; i++)
{
if (check(i))
{
ans++;
}
}
cout << ans << endl;
}
}
signed main()
{
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int _ = 1;
// cin>>_;
while (_--)
solve();
return 0;
}